当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayUtils::iteratorToArray方法代码示例

本文整理汇总了PHP中Zend\Stdlib\ArrayUtils::iteratorToArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtils::iteratorToArray方法的具体用法?PHP ArrayUtils::iteratorToArray怎么用?PHP ArrayUtils::iteratorToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Stdlib\ArrayUtils的用法示例。


在下文中一共展示了ArrayUtils::iteratorToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Sets validator options
  *
  * Mimetype to accept
  * - NULL means default PHP usage by using the environment variable 'magic'
  * - FALSE means disabling searching for mimetype, should be used for PHP 5.3
  * - A string is the mimetype file to use
  *
  * @param  string|array|Traversable $options
  */
 public function __construct($options = null)
 {
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     } elseif (is_string($options)) {
         $this->setMimeType($options);
         $options = [];
     } elseif (is_array($options)) {
         if (isset($options['magicFile'])) {
             $this->setMagicFile($options['magicFile']);
             unset($options['magicFile']);
         }
         if (isset($options['enableHeaderCheck'])) {
             $this->enableHeaderCheck($options['enableHeaderCheck']);
             unset($options['enableHeaderCheck']);
         }
         if (array_key_exists('mimeType', $options)) {
             $this->setMimeType($options['mimeType']);
             unset($options['mimeType']);
         }
         // Handle cases where mimetypes are interspersed with options, or
         // options are simply an array of mime types
         foreach (array_keys($options) as $key) {
             if (!is_int($key)) {
                 continue;
             }
             $this->addMimeType($options[$key]);
             unset($options[$key]);
         }
     }
     parent::__construct($options);
 }
开发者ID:adrenth,项目名称:rssfetcher,代码行数:42,代码来源:MimeType.php

示例2: factory

 /**
  * Create and return a StorageInterface instance
  *
  * @param  string                             $type
  * @param  array|Traversable                  $options
  * @return StorageInterface
  * @throws Exception\InvalidArgumentException for unrecognized $type or individual options
  */
 public static function factory($type, $options = array())
 {
     if (!is_string($type)) {
         throw new Exception\InvalidArgumentException(sprintf('%s expects the $type argument to be a string class name; received "%s"', __METHOD__, is_object($type) ? get_class($type) : gettype($type)));
     }
     if (!class_exists($type)) {
         $class = __NAMESPACE__ . '\\' . $type;
         if (!class_exists($class)) {
             throw new Exception\InvalidArgumentException(sprintf('%s expects the $type argument to be a valid class name; received "%s"', __METHOD__, $type));
         }
         $type = $class;
     }
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (!is_array($options)) {
         throw new Exception\InvalidArgumentException(sprintf('%s expects the $options argument to be an array or Traversable; received "%s"', __METHOD__, is_object($options) ? get_class($options) : gettype($options)));
     }
     switch (true) {
         case in_array('Zend\\Session\\Storage\\AbstractSessionArrayStorage', class_parents($type)):
             return static::createSessionArrayStorage($type, $options);
             break;
         case $type === 'Zend\\Session\\Storage\\ArrayStorage':
         case in_array('Zend\\Session\\Storage\\ArrayStorage', class_parents($type)):
             return static::createArrayStorage($type, $options);
             break;
         case in_array('Zend\\Session\\Storage\\StorageInterface', class_implements($type)):
             return new $type($options);
             break;
         default:
             throw new Exception\InvalidArgumentException(sprintf('Unrecognized type "%s" provided; expects a class implementing %s\\StorageInterface', $type, __NAMESPACE__));
     }
 }
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:41,代码来源:Factory.php

示例3: __construct

 /**
  * Sets validator options
  *
  * @param  string|array|\Traversable $options
  */
 public function __construct($options = null)
 {
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     $case = null;
     if (1 < func_num_args()) {
         $case = func_get_arg(1);
     }
     if (is_array($options)) {
         if (isset($options['case'])) {
             $case = $options['case'];
             unset($options['case']);
         }
         if (!array_key_exists('extension', $options)) {
             $options = array('extension' => $options);
         }
     } else {
         $options = array('extension' => $options);
     }
     if ($case !== null) {
         $options['case'] = $case;
     }
     parent::__construct($options);
 }
开发者ID:paulbriton,项目名称:streaming_diffusion,代码行数:30,代码来源:Extension.php

示例4: factory

 /**
  * Create a captcha adapter instance
  *
  * @param  array|Traversable $options
  * @return AdapterInterface
  * @throws Exception\InvalidArgumentException for a non-array, non-Traversable $options
  * @throws Exception\DomainException if class is missing or invalid
  */
 public static function factory($options)
 {
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (!is_array($options)) {
         throw new Exception\InvalidArgumentException(sprintf('%s expects an array or Traversable argument; received "%s"', __METHOD__, is_object($options) ? get_class($options) : gettype($options)));
     }
     if (!isset($options['class'])) {
         throw new Exception\DomainException(sprintf('%s expects a "class" attribute in the options; none provided', __METHOD__));
     }
     $class = $options['class'];
     if (isset(static::$classMap[strtolower($class)])) {
         $class = static::$classMap[strtolower($class)];
     }
     if (!class_exists($class)) {
         throw new Exception\DomainException(sprintf('%s expects the "class" attribute to resolve to an existing class; received "%s"', __METHOD__, $class));
     }
     unset($options['class']);
     if (isset($options['options'])) {
         $options = $options['options'];
     }
     $captcha = new $class($options);
     if (!$captcha instanceof AdapterInterface) {
         throw new Exception\DomainException(sprintf('%s expects the "class" attribute to resolve to a valid Zend\\Captcha\\AdapterInterface instance; received "%s"', __METHOD__, $class));
     }
     return $captcha;
 }
开发者ID:liuxuezhan,项目名称:my_tool,代码行数:36,代码来源:Factory.php

示例5: setData

 public function setData($data)
 {
     if ($data instanceof Traversable) {
         $data = ArrayUtils::iteratorToArray($data);
     }
     $isAts = isset($data['atsEnabled']) && $data['atsEnabled'];
     $isUri = isset($data['uriApply']) && !empty($data['uriApply']);
     $email = isset($data['contactEmail']) ? $data['contactEmail'] : '';
     if ($isAts && $isUri) {
         $data['atsMode']['mode'] = 'uri';
         $data['atsMode']['uri'] = $data['uriApply'];
         $uri = new Http($data['uriApply']);
         if ($uri->getHost() == $this->host) {
             $data['atsMode']['mode'] = 'intern';
         }
     } elseif ($isAts && !$isUri) {
         $data['atsMode']['mode'] = 'intern';
     } elseif (!$isAts && !empty($email)) {
         $data['atsMode']['mode'] = 'email';
         $data['atsMode']['email'] = $email;
     } else {
         $data['atsMode']['mode'] = 'none';
     }
     if (!array_key_exists('job', $data)) {
         $data = array('job' => $data);
     }
     return parent::setData($data);
 }
开发者ID:utrenkner,项目名称:YAWIK,代码行数:28,代码来源:Import.php

示例6: setValue

 /**
  * Set the element value
  *
  * @param   mixed   $value
  * @return  TagList
  */
 public function setValue($value)
 {
     if ($value instanceof Traversable) {
         $value = ArrayUtils::iteratorToArray($value);
     }
     return parent::setValue((array) $value);
 }
开发者ID:gridguyz,项目名称:core,代码行数:13,代码来源:TagList.php

示例7: __construct

 /**
  * Class constructor
  * (the default encoding is UTF-8)
  *
  * @param array|Traversable $options
  * @return Xml
  */
 public function __construct($options = array())
 {
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (!is_array($options)) {
         $args = func_get_args();
         $options = array('rootElement' => array_shift($args));
         if (count($args)) {
             $options['elementMap'] = array_shift($args);
         }
         if (count($args)) {
             $options['encoding'] = array_shift($args);
         }
         if (count($args)) {
             $options['dateTimeFormat'] = array_shift($args);
         }
     }
     if (!array_key_exists('rootElement', $options)) {
         $options['rootElement'] = 'logEntry';
     }
     if (!array_key_exists('encoding', $options)) {
         $options['encoding'] = 'UTF-8';
     }
     $this->rootElement = $options['rootElement'];
     $this->setEncoding($options['encoding']);
     if (array_key_exists('elementMap', $options)) {
         $this->elementMap = $options['elementMap'];
     }
     if (array_key_exists('dateTimeFormat', $options)) {
         $this->setDateTimeFormat($options['dateTimeFormat']);
     }
 }
开发者ID:totolouis,项目名称:ZF2-Auth,代码行数:40,代码来源:Xml.php

示例8: __construct

    /**
     * Class constructor
     *
     * @param string|array|\Traversable $options Encryption Options
     */
    public function __construct($options)
    {
        if (!extension_loaded('mcrypt')) {
            throw new Exception\ExtensionNotLoadedException('This filter needs the mcrypt extension');
        }

        if ($options instanceof Traversable) {
            $options = ArrayUtils::iteratorToArray($options);
        } elseif (is_string($options)) {
            $options = array('key' => $options);
        } elseif (!is_array($options)) {
            throw new Exception\InvalidArgumentException('Invalid options argument provided to filter');
        }

        if (array_key_exists('compression', $options)) {
            $this->setCompression($options['compression']);
            unset($options['compress']);
        }

        if (array_key_exists('compression', $options)) {
            $this->setCompression($options['compression']);
            unset($options['compress']);
        }

        $this->setEncryption($options);
    }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:31,代码来源:Mcrypt.php

示例9: __construct

    /**
     * Sets default option values for this instance
     *
     * @param  boolean|Traversable|array $allowWhiteSpace
     */
    public function __construct($options = false)
    {
        if ($options instanceof Traversable) {
            $options = ArrayUtils::iteratorToArray($options);
        }
        if (!is_array($options)) {
            $options = func_get_args();
            $temp    = array();
            if (!empty($options)) {
                $temp['allowWhiteSpace'] = array_shift($options);
            }

            if (!empty($options)) {
                $temp['locale'] = array_shift($options);
            }

            $options = $temp;
        }

        if (null === self::$unicodeEnabled) {
            self::$unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false;
        }

        if (array_key_exists('allowWhiteSpace', $options)) {
            $this->setAllowWhiteSpace($options['allowWhiteSpace']);
        }

        if (!array_key_exists('locale', $options)) {
            $options['locale'] = null;
        }

        $this->setLocale($options['locale']);
    }
开发者ID:necrogami,项目名称:zf2,代码行数:38,代码来源:Alnum.php

示例10: listAction

 public function listAction()
 {
     $console = $this->getServiceLocator()->get('console');
     $sm = $this->getServiceLocator();
     $isLocal = $this->params()->fromRoute('local');
     if ($isLocal) {
         $appdir = getcwd();
         echo $appdir;
         if (file_exists($appdir . '/config/autoload/local.php')) {
             $config = (include $appdir . '/config/autoload/local.php');
         } else {
             echo 'FILE NO EXIST' . PHP_EOL;
             $config = array();
         }
     } else {
         $config = $sm->get('Configuration');
     }
     if (!is_array($config)) {
         $config = ArrayUtils::iteratorToArray($config, true);
     }
     $console->writeLine('Configuration:', Color::GREEN);
     // print_r($config);
     $ini = new IniWriter();
     echo $ini->toString($config);
 }
开发者ID:hiranyaopns,项目名称:zend,代码行数:25,代码来源:ConfigController.php

示例11: __construct

    /**
     * Constructor
     *
     * @param array|Traversable|int|null  $typeOrOptions
     * @param bool  $casting
     * @param array $translations
     */
    public function __construct($typeOrOptions = null, $casting = true, $translations = array())
    {
        if ($typeOrOptions !== null) {
            if ($typeOrOptions instanceof Traversable) {
                $typeOrOptions = ArrayUtils::iteratorToArray($typeOrOptions);
            }

            if (is_array($typeOrOptions)) {
                if (isset($typeOrOptions['type'])
                    || isset($typeOrOptions['casting'])
                    || isset($typeOrOptions['translations']))
                {
                    $this->setOptions($typeOrOptions);
                } else {
                    $this->setType($typeOrOptions);
                    $this->setCasting($casting);
                    $this->setTranslations($translations);
                }
            } else {
                $this->setType($typeOrOptions);
                $this->setCasting($casting);
                $this->setTranslations($translations);
            }
        }
    }
开发者ID:Robert-Xie,项目名称:php-framework-benchmark,代码行数:32,代码来源:Boolean.php

示例12: __construct

    /**
     * Sets the filter options
     * Allowed options are
     *     'allowTags'     => Tags which are allowed
     *     'allowAttribs'  => Attributes which are allowed
     *     'allowComments' => Are comments allowed ?
     *
     * @param  string|array|Traversable $options
     * @return void
     */
    public function __construct($options = null)
    {
        if ($options instanceof Traversable) {
            $options = ArrayUtils::iteratorToArray($options);
        }
        if ((!is_array($options)) || (is_array($options) && !array_key_exists('allowTags', $options) &&
            !array_key_exists('allowAttribs', $options) && !array_key_exists('allowComments', $options))) {
            $options = func_get_args();
            $temp['allowTags'] = array_shift($options);
            if (!empty($options)) {
                $temp['allowAttribs'] = array_shift($options);
            }

            if (!empty($options)) {
                $temp['allowComments'] = array_shift($options);
            }

            $options = $temp;
        }

        if (array_key_exists('allowTags', $options)) {
            $this->setTagsAllowed($options['allowTags']);
        }

        if (array_key_exists('allowAttribs', $options)) {
            $this->setAttributesAllowed($options['allowAttribs']);
        }
    }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:38,代码来源:StripTags.php

示例13: __construct

    /**
     * Constructor
     *
     * @param  array|Traversable $options
     */
    public function __construct($options = array())
    {

        if ($options instanceof Traversable) {
            $options = ArrayUtils::iteratorToArray($options);
        }

        if (!is_array($options)) {
            throw new Exception\InvalidArgumentException('Invalid options provided');
        }

        if (isset($options[self::MESSAGE_CLASS])) {
            $this->setMessageClass($options[self::MESSAGE_CLASS]);
        }

        if (isset($options[self::MESSAGESET_CLASS])) {
            $this->setMessageSetClass($options[self::MESSAGESET_CLASS]);
        }

        try {
            $this->_sqs = new AmazonSqs(
                $options[self::AWS_ACCESS_KEY], $options[self::AWS_SECRET_KEY]
            );
        } catch(\Zend\Service\Amazon\Exception $e) {
            throw new Exception\RunTimeException('Error on create: '.$e->getMessage(), $e->getCode(), $e);
        }

        if(isset($options[self::HTTP_ADAPTER])) {
            $this->_sqs->getHttpClient()->setAdapter($options[self::HTTP_ADAPTER]);
        }
    }
开发者ID:necrogami,项目名称:zf2,代码行数:36,代码来源:Sqs.php

示例14: __construct

 public function __construct($options = null)
 {
     parent::__construct($options);
     if ($options instanceof \Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (is_array($options)) {
         if (!empty($options['stream'])) {
             if (!is_array($options['stream'])) {
                 $options['stream'] = ['uri' => $options['stream']];
             }
             if (!empty($options['stream']['uri'])) {
                 $writer = new Stream($options['stream']['uri']);
                 if (!empty($options['stream']['priority'])) {
                     $filter = new Priority($options['stream']['priority']);
                     $writer->addFilter($filter);
                 }
                 $this->addWriter($writer);
             }
         }
         if (!empty($options['slack'])) {
             $writer = new SlackWriter($options['slack']);
             $this->addWriter($writer);
         }
         if (!empty($options['register_error_handler'])) {
             Logger::registerErrorHandler($this);
         }
         if (!empty($options['register_exception_handler'])) {
             Logger::registerExceptionHandler($this);
         }
     }
 }
开发者ID:Mailclark,项目名称:bot2hook,代码行数:32,代码来源:Logger.php

示例15: __construct

 /**
  * Constructor
  *
  * @param MongoC|MongoClient|array|Traversable $mongo
  * @param string $database
  * @param string $collection
  * @param array $saveOptions
  * @throws Exception\InvalidArgumentException
  * @throws Exception\ExtensionNotLoadedException
  */
 public function __construct($mongo, $database = null, $collection = null, array $saveOptions = [])
 {
     if (!extension_loaded('mongo')) {
         throw new Exception\ExtensionNotLoadedException('Missing ext/mongo');
     }
     if ($mongo instanceof Traversable) {
         // Configuration may be multi-dimensional due to save options
         $mongo = ArrayUtils::iteratorToArray($mongo);
     }
     if (is_array($mongo)) {
         parent::__construct($mongo);
         $saveOptions = isset($mongo['save_options']) ? $mongo['save_options'] : [];
         $collection = isset($mongo['collection']) ? $mongo['collection'] : null;
         $database = isset($mongo['database']) ? $mongo['database'] : null;
         $mongo = isset($mongo['mongo']) ? $mongo['mongo'] : null;
     }
     if (null === $collection) {
         throw new Exception\InvalidArgumentException('The collection parameter cannot be empty');
     }
     if (null === $database) {
         throw new Exception\InvalidArgumentException('The database parameter cannot be empty');
     }
     if (!($mongo instanceof MongoClient || $mongo instanceof MongoC)) {
         throw new Exception\InvalidArgumentException(sprintf('Parameter of type %s is invalid; must be MongoClient or Mongo', is_object($mongo) ? get_class($mongo) : gettype($mongo)));
     }
     $this->mongoCollection = $mongo->selectCollection($database, $collection);
     $this->saveOptions = $saveOptions;
 }
开发者ID:zendframework,项目名称:zend-log,代码行数:38,代码来源:Mongo.php


注:本文中的Zend\Stdlib\ArrayUtils::iteratorToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。