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


PHP ArrayUtils::iteratorToArray方法代码示例

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


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

示例1: isValid

 /**
  * Defined by Zend\Validator\ValidatorInterface
  *
  * Returns true if all values validate true
  *
  * @param  mixed $value
  * @param  mixed $context Additional context
  * @return bool
  * @throws RuntimeException
  */
 public function isValid($value, $context = null)
 {
     $this->setValue($value);
     if ($value instanceof Traversable) {
         $value = ArrayUtils::iteratorToArray($value);
     }
     if (is_array($value)) {
         $values = $value;
     } elseif (is_string($value)) {
         $delimiter = $this->getValueDelimiter();
         // Skip explode if delimiter is null,
         // used when value is expected to be either an
         // array when multiple values and a string for
         // single values (ie. MultiCheckbox form behavior)
         $values = null !== $delimiter ? explode($this->valueDelimiter, $value) : array($value);
     } else {
         $values = array($value);
     }
     $validator = $this->getValidator();
     if (!$validator) {
         throw new RuntimeException(sprintf('%s expects a validator to be set; none given', __METHOD__));
     }
     foreach ($values as $value) {
         // provide context to validators isValid method
         if (!$validator->isValid($value, $context)) {
             $this->abstractOptions['messages'][] = $validator->getMessages();
             if ($this->isBreakOnFirstFailure()) {
                 return false;
             }
         }
     }
     return count($this->abstractOptions['messages']) == 0;
 }
开发者ID:kanellov,项目名称:zf2-validator,代码行数:43,代码来源:ExplodeWithContext.php

示例2: createService

 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config');
     if ($config instanceof Traversable) {
         $config = ArrayUtils::iteratorToArray($config);
     }
     return new TwitterInfoService($config['twitter']['cache_path']);
 }
开发者ID:krsreenatha,项目名称:php.ug,代码行数:15,代码来源:TwitterInfoFactory.php

示例3: __construct

 public function __construct($options = null)
 {
     $this->_config = new Config\Oauth2Config();
     if ($options !== null) {
         if ($options instanceof Traversable) {
             $options = ArrayUtils::iteratorToArray($options);
         }
         $this->_config->setOptions($options);
     }
 }
开发者ID:ahyswang,项目名称:eva-engine,代码行数:10,代码来源:Consumer.php

示例4: __construct

 public function __construct($options = null)
 {
     // The abstract constructor allows no scalar values
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (is_array($options)) {
         $this->setOptions($options);
     }
 }
开发者ID:pedro151,项目名称:zfcomplement,代码行数:10,代码来源:AbstractConfig.php

示例5: getIndexLocation

 public function getIndexLocation()
 {
     // выборка конфигурации из конфигурационных данных модуля
     $config = $this->getServiceLocator()->get('config');
     if ($config instanceof Traversable) {
         $config = ArrayUtils::iteratorToArray($config);
     }
     if (!empty($config['module_config']['search_index'])) {
         return $config['module_config']['search_index'];
     } else {
         return FALSE;
     }
 }
开发者ID:seyfer,项目名称:zend2-tutorial.me,代码行数:13,代码来源:BaseController.php

示例6: getFileUploadLocation

 public function getFileUploadLocation()
 {
     // Fetch Configuration from Module Config
     $config = $this->getServiceLocator()->get('config');
     if ($config instanceof Traversable) {
         $config = ArrayUtils::iteratorToArray($config);
     }
     if (!empty($config['module_config']['image_upload_location'])) {
         return $config['module_config']['image_upload_location'];
     } else {
         return FALSE;
     }
 }
开发者ID:trungtranthanh93,项目名称:zendCommunication,代码行数:13,代码来源:MediaManagerController.php

示例7: createService

 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config');
     if ($config instanceof Traversable) {
         $config = ArrayUtils::iteratorToArray($config);
     }
     $config = $config['phpug']['notification']['transport'];
     $transport = $serviceLocator->get($config['class']);
     if (method_exists($transport, 'setOptions')) {
         $transportOptions = new $config['optionclass']($config['options']);
         $transport->setOptions($transportOptions);
     }
     return $transport;
 }
开发者ID:krsreenatha,项目名称:php.ug,代码行数:21,代码来源:TransportFactory.php

示例8: __construct

 public function __construct($options = null)
 {
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (isset($options['data'])) {
         $this->setData($options['data']);
     }
     if (!array_key_exists('field', $options)) {
         throw new Exception\InvalidArgumentException("Missing option 'field'");
     }
     $this->setField($options['field']);
     parent::__construct($options);
 }
开发者ID:ahyswang,项目名称:eva-engine,代码行数:14,代码来源:EqualTo.php

示例9: setValue

 /**
  * {@inheritDoc}
  */
 public function setValue($value)
 {
     if ($this->isMultiple()) {
         if ($value instanceof \Traversable) {
             $value = ArrayUtils::iteratorToArray($value);
         } elseif (!$value) {
             return parent::setValue([]);
         } elseif (!is_array($value)) {
             $value = (array) $value;
         }
         return parent::setValue(array_map(Locale::class . '::canonicalize', $value));
     }
     return parent::setValue(Locale::canonicalize($value));
 }
开发者ID:coolms,项目名称:common,代码行数:17,代码来源:LocaleSelect.php

示例10: __construct

 /**
  * Constructor for the integer validator
  *
  * @param string|Zend_Locale $locale
  */
 public function __construct($options = [])
 {
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (array_key_exists('locale', $options)) {
         $this->setLocale($options['locale']);
     } else {
         if (Zend_Registry::isRegistered('Zend_Locale')) {
             $locale = Zend_Registry::get('Zend_Locale');
             $this->setLocale($locale);
         }
     }
     parent::__construct($options);
 }
开发者ID:argentinaluiz,项目名称:js_zf2_library,代码行数:20,代码来源:JSInt.php

示例11: setOptions

 /**
  * Set configuration parameters for this Api caller
  *
  * @param  array|Traversable $options
  * @return Api
  * @throws \Exception
  */
 public function setOptions($options = array())
 {
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (!is_array($options)) {
         throw new \Exception('Config parameter is not valid');
     }
     /** Config Key Normalization */
     foreach ($options as $k => $v) {
         $this->config[str_replace(array('-', '_', ' ', '.'), '', strtolower($k))] = $v;
         // replace w/ normalized
     }
     return $this;
 }
开发者ID:carnage,项目名称:mailchimp,代码行数:22,代码来源:Api.php

示例12: __construct

 /**
  * @param array $options
  * @param array $extends
  */
 public function __construct($options = array(), $extends = array())
 {
     // The abstract constructor allows no scalar values
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (!empty($extends)) {
         if ($extends instanceof Traversable) {
             $extends = ArrayUtils::iteratorToArray($extends);
         }
         $this->extends = array_intersect_key($options, $extends);
     }
     if (is_array($options)) {
         $this->setOptions($options);
     }
 }
开发者ID:pedro151,项目名称:zfcomplement,代码行数:20,代码来源:Config.php

示例13: setOptions

 /**
  * {@inheritDoc}
  */
 public function setOptions($options)
 {
     parent::setOptions($options);
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (isset($options['max'])) {
         $this->setMax($options['max']);
     }
     if (isset($options['min'])) {
         $this->setMin($options['min']);
     }
     if (isset($options['step'])) {
         $this->setStep($options['step']);
     }
 }
开发者ID:coolms,项目名称:common,代码行数:19,代码来源:Number.php

示例14: setOptions

 public function setOptions($options)
 {
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     } elseif (!is_array($options)) {
         throw new InvalidArgumentException('The options parameter must be an array or a Traversable');
     }
     if (isset($options['queryMap'])) {
         $this->setQueryMap($options['queryMap']);
     }
     if (isset($options["namespaces"])) {
         $this->setNamespaces($options["namespaces"]);
     }
     if (isset($options["xpath"])) {
         $this->setXPath($options["xpath"]);
     }
     return $this;
 }
开发者ID:vmalinovskiy,项目名称:CallFire-PHP-SDK,代码行数:18,代码来源:DOM.php

示例15: getServiceConfig

 public function getServiceConfig()
 {
     return array('factories' => array('wpdbManager' => function ($sm) {
         $config = $sm->get('config');
         if ($config instanceof Traversable) {
             $config = ArrayUtils::iteratorToArray($config);
         }
         /* process wp settings for wp native calls */
         if (isset($config['wp_config']['wp_debug'])) {
             define('WP_DEBUG', $config['wp_config']['wp_debug']);
         } else {
             define('WP_DEBUG', false);
         }
         $wpdbm = new Service\WpdbManager();
         $wpdbm->setServiceManager($sm);
         $wpdbm->setDatabase($config['wp_config']);
         return $wpdbm;
     }));
 }
开发者ID:jonsource,项目名称:zf2wp,代码行数:19,代码来源:Module.php


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