當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。