php Zend-Stdlib-ArrayUtils类(方法)实例源码

下面列出了php Zend-Stdlib-ArrayUtils 类(方法)源码代码实例,从而了解它的用法。

作者:andreas-serl    项目:athene   
public function forwardAction()
 {
     $alias = $this->params('alias');
     $instance = $this->getInstanceManager()->getInstanceFromRequest();
     try {
         $location = $this->aliasManager->findCanonicalAlias($alias, $instance);
         $this->redirect()->toUrl($location);
         $this->getResponse()->setStatusCode(301);
         return false;
     } catch (CanonicalUrlNotFoundException $e) {
     }
     try {
         $source = $this->aliasManager->findSourceByAlias($alias);
     } catch (AliasNotFoundException $e) {
         $this->getResponse()->setStatusCode(404);
         return false;
     }
     $router = $this->getServiceLocator()->get('Router');
     $request = new Request();
     $request->setMethod(Request::METHOD_GET);
     $request->setUri($source);
     $routeMatch = $router->match($request);
     if ($routeMatch === null) {
         $this->getResponse()->setStatusCode(404);
         return false;
     }
     $this->getEvent()->setRouteMatch($routeMatch);
     $params = $routeMatch->getParams();
     $controller = $params['controller'];
     $return = $this->forward()->dispatch($controller, ArrayUtils::merge($params, ['forwarded' => true]));
     return $return;
 }

作者:tejdeep    项目:tejcs.co   
/**
  * 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__));
     }
 }

作者:gingerwfm    项目:wf-configurator-backen   
public static function init()
 {
     // Load the user-defined test configuration file, if it exists; otherwise, load
     if (is_readable(__DIR__ . '/TestConfig.php')) {
         $testConfig = (include __DIR__ . '/TestConfig.php');
     } else {
         $testConfig = (include __DIR__ . '/TestConfig.php.dist');
     }
     $zf2ModulePaths = array();
     if (isset($testConfig['module_listener_options']['module_paths'])) {
         $modulePaths = $testConfig['module_listener_options']['module_paths'];
         foreach ($modulePaths as $modulePath) {
             if ($path = static::findParentPath($modulePath)) {
                 $zf2ModulePaths[] = $path;
             }
         }
     }
     $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
     $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
     static::initAutoloader();
     // use ModuleManager to load this module and it's dependencies
     $baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)));
     $config = ArrayUtils::merge($baseConfig, $testConfig);
     $serviceManager = new ServiceManager(new ServiceManagerConfig());
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     static::$serviceManager = $serviceManager;
     static::$config = $config;
 }

作者:liuxuezha    项目:my_too   
/**
  * 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;
 }

作者:adrent    项目:rssfetche   
/**
  * 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);
 }

作者:utrenkne    项目:YAWI   
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);
 }

作者:paulbrito    项目:streaming_diffusio   
/**
  * 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);
 }

作者:zfcampu    项目:zf-content-validatio   
/**
  * Create and return a NoRecordExists validator.
  *
  * @param ContainerInterface $container
  * @param string $requestedName
  * @param null|array $options
  * @return NoRecordExists
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     if (isset($options['adapter'])) {
         return new NoRecordExists(ArrayUtils::merge($options, ['adapter' => $container->get($options['adapter'])]));
     }
     return new NoRecordExists($options);
 }

作者:stefanotorres    项目:BsbFlysyste   
/**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return AdapterManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config');
     $config = $config['bsb_flysystem'];
     $serviceConfig = isset($config['adapter_manager']['config']) ? $config['adapter_manager']['config'] : [];
     $adapterMap = $this->adapterMap;
     if (isset($config['adapter_map'])) {
         $adapterMap = ArrayUtils::merge($this->adapterMap, $config['adapter_map']);
     }
     foreach ($config['adapters'] as $name => $adapterConfig) {
         if (!isset($adapterConfig['type'])) {
             throw new UnexpectedValueException(sprintf("Missing 'type' key for the adapter '%s' configuration", $name));
         }
         $type = strtolower($adapterConfig['type']);
         foreach (array_keys($adapterMap) as $serviceKind) {
             if (isset($adapterMap[$serviceKind][$type])) {
                 $serviceConfig[$serviceKind][$name] = $adapterMap[$serviceKind][$type];
                 if (isset($adapterConfig['shared'])) {
                     $serviceConfig['shared'][$name] = filter_var($adapterConfig['shared'], FILTER_VALIDATE_BOOLEAN);
                 }
                 continue 2;
             }
         }
         throw new UnexpectedValueException(sprintf("Unknown adapter type '%s'", $type));
     }
     $serviceConfig = new Config($serviceConfig);
     return new AdapterManager($serviceConfig);
 }

作者:zendframewor    项目:zendclou   
/**
  * 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::AWS_ACCESS_KEY]) || !isset($options[self::AWS_SECRET_KEY])) {
         throw new Exception\InvalidArgumentException('AWS keys not specified!');
     }
     try {
         $this->_s3 = new AmazonS3($options[self::AWS_ACCESS_KEY], $options[self::AWS_SECRET_KEY]);
     } catch (\ZendService\Amazon\S3\Exception $e) {
         throw new Exception\RuntimeException('Error on create: ' . $e->getMessage(), $e->getCode(), $e);
     }
     if (isset($options[self::HTTP_ADAPTER])) {
         $this->_s3->getHttpClient()->setAdapter($options[self::HTTP_ADAPTER]);
     }
     if (isset($options[self::BUCKET_NAME])) {
         $this->_defaultBucketName = $options[self::BUCKET_NAME];
     }
     if (isset($options[self::BUCKET_AS_DOMAIN])) {
         $this->_defaultBucketAsDomain = $options[self::BUCKET_AS_DOMAIN];
     }
 }

作者:shraddhaneg    项目:KJSench   
/**
  * Set the data
  * @param array $data [description]
  */
 public function setData(array $data)
 {
     if (ArrayUtils::isHashTable($data)) {
         $data = array($data);
     }
     $this->data = $data;
 }

作者:karnuri    项目:zf2-turtoria   
/**
  * @param array $spec
  * @return TransportInterface
  * @throws Exception\InvalidArgumentException
  * @throws Exception\DomainException
  */
 public static function create($spec = array())
 {
     if ($spec instanceof Traversable) {
         $spec = ArrayUtils::iteratorToArray($spec);
     }
     if (!is_array($spec)) {
         throw new Exception\InvalidArgumentException(sprintf('%s expects an array or Traversable argument; received "%s"', __METHOD__, is_object($spec) ? get_class($spec) : gettype($spec)));
     }
     $type = isset($spec['type']) ? $spec['type'] : 'sendmail';
     $normalizedType = strtolower($type);
     if (isset(static::$classMap[$normalizedType])) {
         $type = static::$classMap[$normalizedType];
     }
     if (!class_exists($type)) {
         throw new Exception\DomainException(sprintf('%s expects the "type" attribute to resolve to an existing class; received "%s"', __METHOD__, $type));
     }
     $transport = new $type();
     if (!$transport instanceof TransportInterface) {
         throw new Exception\DomainException(sprintf('%s expects the "type" attribute to resolve to a valid' . ' Zend\\Mail\\Transport\\TransportInterface instance; received "%s"', __METHOD__, $type));
     }
     if ($transport instanceof Smtp && isset($spec['options'])) {
         $transport->setOptions(new SmtpOptions($spec['options']));
     }
     if ($transport instanceof File && isset($spec['options'])) {
         $transport->setOptions(new FileOptions($spec['options']));
     }
     return $transport;
 }

作者:jbarentse    项目:dr   
public function createModelFromConfigArrays(array $global, array $local)
    {
        $this->configWriter->toFile($this->globalConfigPath, $global);
        $this->configWriter->toFile($this->localConfigPath, $local);
        $mergedConfig = ArrayUtils::merge($global, $local);
        $globalConfig = new ConfigResource($mergedConfig, $this->globalConfigPath, $this->configWriter);
        $localConfig  = new ConfigResource($mergedConfig, $this->localConfigPath, $this->configWriter);


        $moduleEntity = $this->getMockBuilder('ZF\Apigility\Admin\Model\ModuleEntity')
                            ->disableOriginalConstructor()
                            ->getMock();

        $moduleEntity->expects($this->any())
                     ->method('getName')
                     ->will($this->returnValue('Foo'));

        $moduleEntity->expects($this->any())
                     ->method('getVersions')
                     ->will($this->returnValue(array(1,2)));

        $moduleModel = $this->getMockBuilder('ZF\Apigility\Admin\Model\ModuleModel')
                            ->disableOriginalConstructor()
                            ->getMock();

        $moduleModel->expects($this->any())
                    ->method('getModules')
                    ->will($this->returnValue(array('Foo' => $moduleEntity)));

        return new AuthenticationModel($globalConfig, $localConfig, $moduleModel);
    }

作者:kedward    项目:knc-erro   
public static function init()
 {
     if (is_readable(__DIR__ . '/config.php')) {
         $testConfig = (include __DIR__ . '/config.php');
     } else {
         $testConfig = (include __DIR__ . '/config.php.dist');
     }
     $moduleName = pathinfo(realpath(dirname(__DIR__)), PATHINFO_BASENAME);
     if (defined('MODULE_NAME')) {
         $moduleName = MODULE_NAME;
     }
     $zf2ModulePaths = array(dirname(dirname(__DIR__)));
     if ($path = static::findParentPath('vendor')) {
         $modulePaths[] = $path;
     }
     if (($path = static::findParentPath('module')) !== $modulePaths[0]) {
         $modulePaths[] = $path;
     }
     if (isset($additionalModulePaths)) {
         $zf2ModulePaths = array_merge($modulePaths, $additionalModulePaths);
     } else {
         $zf2ModulePaths = $modulePaths;
     }
     $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
     static::initAutoloader();
     $baseConfig = ['module_listener_options' => ['module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)], 'modules' => [$moduleName]];
     $config = ArrayUtils::merge($baseConfig, $testConfig);
     $serviceManager = new ServiceManager(new ServiceManagerConfig());
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     static::$serviceManager = $serviceManager;
 }

作者:paulbrito    项目:streaming_diffusio   
/**
  * Class constructor
  *
  * @param string|array|Traversable $options (Optional) Options to set, if null mcrypt is used
  */
 public function __construct($options = null)
 {
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     $this->setAdapter($options);
 }

作者:weierophinne    项目:zend-expressive-templat   
/**
  * Returns merged global, template-specific and given params
  *
  * @param string $template
  * @param array $params
  * @return array
  */
 private function mergeParams($template, array $params)
 {
     $globalDefaults = isset($this->defaultParams[TemplateRendererInterface::TEMPLATE_ALL]) ? $this->defaultParams[TemplateRendererInterface::TEMPLATE_ALL] : [];
     $templateDefaults = isset($this->defaultParams[$template]) ? $this->defaultParams[$template] : [];
     $defaults = ArrayUtils::merge($globalDefaults, $templateDefaults);
     return ArrayUtils::merge($defaults, $params);
 }

作者:totoloui    项目:ZF2-Aut   
/**
  * 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']);
     }
 }

作者:VOONWerbeagentu    项目:SoliantEntityAudi   
public static function init()
 {
     // Load the user-defined test configuration file, if it exists; otherwise, load
     if (is_readable(__DIR__ . '/TestConfig.php')) {
         $testConfig = (include __DIR__ . '/TestConfig.php');
     } else {
         $testConfig = (include __DIR__ . '/TestConfig.php.dist');
     }
     $zf2ModulePaths = array();
     if (isset($testConfig['module_listener_options']['module_paths'])) {
         $modulePaths = $testConfig['module_listener_options']['module_paths'];
         foreach ($modulePaths as $modulePath) {
             if ($path = static::findParentPath($modulePath)) {
                 $zf2ModulePaths[] = $path;
             }
         }
     }
     $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
     $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
     static::initAutoloader();
     // use ModuleManager to load this module and it's dependencies
     $baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)));
     $config = ArrayUtils::merge($baseConfig, $testConfig);
     $application = \Zend\Mvc\Application::init($config);
     // build test database
     $entityManager = $application->getServiceManager()->get('doctrine.entitymanager.orm_default');
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($entityManager);
     $schemaTool->createSchema($entityManager->getMetadataFactory()->getAllMetadata());
     static::$application = $application;
 }

作者:idwsdt    项目:INIT-fram   
/**
  * Sets filter options
  *
  * @param array|Traversable $options
  */
 public function __construct($options = array())
 {
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (!is_array($options)) {
         $options = func_get_args();
         $temp['quotestyle'] = array_shift($options);
         if (!empty($options)) {
             $temp['charset'] = array_shift($options);
         }
         $options = $temp;
     }
     if (!isset($options['quotestyle'])) {
         $options['quotestyle'] = ENT_QUOTES;
     }
     if (!isset($options['encoding'])) {
         $options['encoding'] = 'UTF-8';
     }
     if (isset($options['charset'])) {
         $options['encoding'] = $options['charset'];
     }
     if (!isset($options['doublequote'])) {
         $options['doublequote'] = true;
     }
     $this->setQuoteStyle($options['quotestyle']);
     $this->setEncoding($options['encoding']);
     $this->setDoubleQuote($options['doublequote']);
 }

作者:Flesh19    项目:magent   
/**
  * Set the list of items to white-list.
  *
  * @param array|Traversable $list
  */
 public function setList($list = array())
 {
     if (!is_array($list)) {
         $list = ArrayUtils::iteratorToArray($list);
     }
     $this->list = $list;
 }


问题


面经


文章

微信
公众号

扫码关注公众号