本文整理汇总了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;
}
示例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']);
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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);
}
示例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));
}
示例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);
}
示例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;
}
示例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);
}
}
示例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']);
}
}
示例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;
}
示例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;
}));
}