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


PHP ArrayUtils::merge方法代码示例

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


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

示例1: forwardAction

 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;
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:32,代码来源:AliasController.php

示例2: init

 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;
 }
开发者ID:gingerwfms,项目名称:wf-configurator-backend,代码行数:29,代码来源:Bootstrap.php

示例3: createService

 /**
  * 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);
 }
开发者ID:stefanotorresi,项目名称:BsbFlysystem,代码行数:34,代码来源:AdapterManagerFactory.php

示例4: __invoke

 /**
  * 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);
 }
开发者ID:zfcampus,项目名称:zf-content-validation,代码行数:15,代码来源:NoRecordExistsFactory.php

示例5: init

 /**
  * Module ini function that import the current domain files or it's alias
  *
  * @param ModuleManager $moduleManager
  */
 public function init(ModuleManager $moduleManager)
 {
     $events = $moduleManager->getEventManager();
     $events->attach(ModuleEvent::EVENT_MERGE_CONFIG, function (EventInterface $e) {
         $configListener = $e->getConfigListener();
         $config = $configListener->getMergedConfig(false);
         $domain = DomainService::getDomain();
         $domainDir = null;
         if (!isset($config[$domain])) {
             if (isset($config['losdomain']['domain_dir'])) {
                 $domainDir = $config['losdomain']['domain_dir'];
                 $domainConfig = DomainOptions::importDomain($domainDir, $domain);
                 $config = ArrayUtils::merge($config, $domainConfig);
                 $configListener->setMergedConfig($config);
             }
         }
         if ($domainDir !== null && isset($config[$domain]) && array_key_exists('alias', $config[$domain])) {
             $alias = $config[$domain]['alias'];
             $aliasConfig = DomainOptions::importDomain($domainDir, $alias);
             $config[$domain] = $aliasConfig[$alias];
             $config = ArrayUtils::merge($config, $aliasConfig);
             unset($config[$alias]);
             $configListener->setMergedConfig($config);
         }
     });
 }
开发者ID:Ellipizle,项目名称:LosDomain,代码行数:31,代码来源:Module.php

示例6: createService

 /**
  * Create service
  *
  * @param  ServiceLocatorInterface $validators
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $validators)
 {
     if (isset($this->options['entity_class'])) {
         return new ObjectExists(ArrayUtils::merge($this->options, array('object_repository' => $validators->getServiceLocator()->get('Doctrine\\ORM\\EntityManager')->getRepository($this->options['entity_class']))));
     }
     return new ObjectExists($this->options);
 }
开发者ID:API-Skeletons,项目名称:zf-apigility-doctrine,代码行数:13,代码来源:ObjectExistsFactory.php

示例7: onConfigMerge

 /**
  *
  * @param \Zend\EventManager\Event $event
  */
 public function onConfigMerge(ModuleEvent $event)
 {
     $config = $event->getConfigListener()->getMergedConfig(false);
     foreach ($config['sds']['doctrineExtensions']['manifest'] as $name => $manifestConfig) {
         if (!isset($manifestConfig['initalized']) || !$manifestConfig['initalized']) {
             $manifest = new Manifest($manifestConfig);
             $manifestConfig = $manifest->toArray();
             $config['sds']['doctrineExtensions']['manifest'][$name] = $manifestConfig;
             //alias documentManager
             //add delegators
             $documentManagerConfig = $config;
             foreach (explode('.', $manifestConfig['document_manager']) as $key) {
                 $documentManagerConfig = $documentManagerConfig[$key];
             }
             $delegatorConfig = ['delegators' => [$manifestConfig['document_manager'] => ['doctrineExtensions.' . $name . '.documentManagerDelegatorFactory'], $documentManagerConfig['eventmanager'] => ['doctrineExtensions.' . $name . '.eventManagerDelegatorFactory'], $documentManagerConfig['configuration'] => ['doctrineExtensions.' . $name . '.configurationDelegatorFactory']]];
             $config['service_manager'] = ArrayUtils::merge($config['service_manager'], $delegatorConfig);
         }
     }
     if (!isset($config['sds']['doctrineExtensions']['manifest']['default']) || !isset($config['sds']['doctrineExtensions']['manifest']['default']['extension_configs']['extension.dojo'])) {
         //remove dojo_src.default route if doctrineExtensions.dojo.default is not configured
         unset($config['router']['routes']['dojo.default']);
     }
     if (!isset($config['sds']['doctrineExtensions']['manifest']['default']) || !isset($config['sds']['doctrineExtensions']['manifest']['default']['extension_configs']['extension.rest'])) {
         //remove rest.default route if doctrineExtensions.rest.default is not configured
         unset($config['router']['routes']['rest.default']);
     }
     $event->getConfigListener()->setMergedConfig($config);
 }
开发者ID:superdweebie,项目名称:doctrine-extensions-module,代码行数:32,代码来源:Module.php

示例8: init

 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;
 }
开发者ID:VOONWerbeagentur,项目名称:SoliantEntityAudit,代码行数:30,代码来源:Bootstrap.php

示例9: createModelFromConfigArrays

    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);
    }
开发者ID:jbarentsen,项目名称:drb,代码行数:31,代码来源:AuthenticationModelTest.php

示例10: start

 /**
  * Start session
  *
  * if No session currently exists, attempt to start it. Calls
  * {@link isValid()} once session_start() is called, and raises an
  * exception if validation fails.
  *
  * @param bool $preserveStorage        If set to true, current session storage will not be overwritten by the
  *                                     contents of $_SESSION.
  * @return void
  * @throws Exception\RuntimeException
  */
 public function start($preserveStorage = false)
 {
     if ($this->sessionExists()) {
         return;
     }
     $saveHandler = $this->getSaveHandler();
     if ($saveHandler instanceof SaveHandler\SaveHandlerInterface) {
         // register the session handler with ext/session
         $this->registerSaveHandler($saveHandler);
     }
     $oldSessionData = array();
     if (null !== $_SESSION) {
         $oldSessionData = $_SESSION;
     }
     if (session_status() === PHP_SESSION_NONE) {
         session_start();
     }
     if ($oldSessionData instanceof \Traversable || is_array($oldSessionData) && 0 === count($oldSessionData)) {
         $_SESSION = ArrayUtils::merge($oldSessionData, $_SESSION, true);
     }
     $storage = $this->getStorage();
     // Since session is starting, we need to potentially repopulate our
     // session storage
     if ($storage instanceof Storage\SessionStorage && $_SESSION !== $storage) {
         if (!$preserveStorage) {
             $storage->fromArray($_SESSION);
         }
         $_SESSION = $storage;
     } elseif ($storage instanceof Storage\StorageInitializationInterface) {
         $storage->init($_SESSION);
     }
     if (!$this->isValid()) {
         throw new Exception\RuntimeException('Session validation failed');
     }
 }
开发者ID:twowholeworms,项目名称:vinari-core,代码行数:47,代码来源:SessionManager.php

示例11: __invoke

 /**
  * @inheritdoc
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $config = $container->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']);
         if (!in_array($type, array_keys($adapterMap['factories']), false)) {
             throw new UnexpectedValueException(sprintf("Unknown adapter type '%s'", $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);
                 }
             }
         }
     }
     return new AdapterManager($container, $serviceConfig);
 }
开发者ID:bushbaby,项目名称:BsbFlysystem,代码行数:31,代码来源:AdapterManagerFactory.php

示例12: filter

 /**
  * @see \Zend\Filter\FilterInterface::filter()
  * @param mixed $value
  * @return mixed Original value, if not a string, or an array of key/value pairs
  */
 public function filter($value)
 {
     if (!is_string($value)) {
         return $value;
     }
     // check if the value provided resembles a query string
     $pairs = explode('&', $value);
     foreach ($pairs as $pair) {
         list($k, $v) = explode('=', $pair);
         // Check if we have a normal key-value pair
         if (!preg_match("/^(.*?)((\\[(.*?)\\])+)\$/m", $k, $m)) {
             $data[$k] = $v;
             continue;
         }
         // Array values
         $parts = explode('][', rtrim(ltrim($m[2], '['), ']'));
         $json = '{"' . implode('":{"', $parts) . '": ' . json_encode($v) . str_pad('', count($parts), '}');
         if (isset($data[$m[1]])) {
             $data[$m[1]] = ArrayUtils::merge($data[$m[1]], $this->jsonFilter->filter($json));
             continue;
         }
         $data[$m[1]] = $this->jsonFilter->filter($json);
     }
     return $data;
 }
开发者ID:pt-pl,项目名称:zf-console,代码行数:30,代码来源:QueryString.php

示例13: init

 public static function init()
 {
     // Load the user-defined test configuration file, if it exists; otherwise, load
     if (is_readable(__DIR__ . '/application.config.php')) {
         $testConfig = (include __DIR__ . '/application.config.php');
     } else {
         $testConfig = (include __DIR__ . '/application.config.php.dist');
     }
     chdir(__DIR__ . '/..');
     $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();
     $entityManager = $serviceManager->get('doctrine.entitymanager.orm_default');
     $eventManager = $entityManager->getEventManager();
     $eventManager->addEventSubscriber(new \Aaa\EntityEvents\PrePersistListener(null));
     static::$eventManager = $eventManager;
     static::$serviceManager = $serviceManager;
     static::$config = $config;
     // static::createSchemaFromEntities();
 }
开发者ID:ifigenija,项目名称:server,代码行数:35,代码来源:_bootstrap.ooo.php

示例14: extendRoutes

 /**
  * @param ModuleEvent $e
  * @throws InvalidArgumentException
  */
 public function extendRoutes(ModuleEvent $e)
 {
     $configListener = $e->getConfigListener();
     $config = $configListener->getMergedConfig(false);
     // Allow extension of routes with overriding capability
     if (isset($config['router']['inheritance']) && is_array($config['router']['inheritance'])) {
         foreach ($config['router']['inheritance'] as $newRoute => $routeConfig) {
             // Not going to override any existing routes
             if (isset($config['router']['routes'][$newRoute])) {
                 throw new InvalidArgumentException('Cannot extend route to existing route id.');
             }
             // parent route must be provided
             if (!isset($routeConfig['extends'])) {
                 throw new InvalidArgumentException('Parent route must be defined.');
             }
             // parent route must exist
             if (!isset($config['router']['routes'][$routeConfig['extends']])) {
                 throw new InvalidArgumentException('Parent route does not exist.');
             }
             // If there is any configuration provided, it must be iterable
             if (isset($routeConfig['configuration']) && !is_array($routeConfig['configuration'])) {
                 throw new InvalidArgumentException('Route overrides must be iterable.');
             }
             // Copying the parent config and merging in the overrides
             $newRouteConfig = $config['router']['routes'][$routeConfig['extends']];
             $newRouteConfig = ArrayUtils::merge($newRouteConfig, $routeConfig['configuration']);
             $config['router']['routes'][$newRoute] = $newRouteConfig;
         }
         // Removing this node so this isn't re-executed
         unset($config['router']['inheritance']);
     }
     // Pass the changed configuration back to the listener:
     $configListener->setMergedConfig($config);
 }
开发者ID:hickeroar,项目名称:zf2-route-inheritance,代码行数:38,代码来源:Module.php

示例15: __construct

 /**
  * Constructor
  *
  * Merges internal arrays with those passed via configuration, and also
  * defines:
  *
  * - factory for the service 'SharedEventManager'.
  * - initializer for EventManagerAwareInterface implementations
  *
  * @param  array $config
  */
 public function __construct(array $config = [])
 {
     $this->config['factories']['ServiceManager'] = function ($container) {
         return $container;
     };
     $this->config['factories']['SharedEventManager'] = function () {
         return new SharedEventManager();
     };
     $this->config['initializers'] = ArrayUtils::merge($this->config['initializers'], ['EventManagerAwareInitializer' => function ($first, $second) {
         if ($first instanceof ContainerInterface) {
             $container = $first;
             $instance = $second;
         } else {
             $container = $second;
             $instance = $first;
         }
         if (!$instance instanceof EventManagerAwareInterface) {
             return;
         }
         $eventManager = $instance->getEventManager();
         // If the instance has an EM WITH an SEM composed, do nothing.
         if ($eventManager instanceof EventManagerInterface && $eventManager->getSharedManager() instanceof SharedEventManagerInterface) {
             return;
         }
         $instance->setEventManager($container->get('EventManager'));
     }]);
     // In zend-servicemanager v2, incoming configuration is not merged
     // with existing; it replaces. So we need to detect that and merge.
     if (method_exists($this, 'getAllowOverride')) {
         $config = ArrayUtils::merge($this->config, $config);
     }
     parent::__construct($config);
 }
开发者ID:zendframework,项目名称:zend-mvc,代码行数:44,代码来源:ServiceManagerConfig.php


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