php Zend-ModuleManager-ModuleEvent类(方法)实例源码

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

作者:superdweebi    项目:doctrine-extensions-modul   
/**
  *
  * @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);
 }

作者:alex-oleshkevic    项目:zf-annotation   
/**
  * @param ModuleEvent $event
  * @throws Exception
  */
 public function onMergeConfig(ModuleEvent $event)
 {
     // do not parse annotations if config cache is enabled.
     $config = $event->getConfigListener()->getMergedConfig(false);
     $annotationReader = AnnotationReaderFactory::factory($config['zf_annotation']);
     $parser = ClassParserFactory::factory($config, $event->getTarget()->getEventManager(), $annotationReader);
     $scanner = new DirectoryScanner();
     $classesToParse = [];
     $modules = $event->getTarget()->getLoadedModules();
     $modulesAllowedToScan = $config['zf_annotation']['scan_modules'];
     foreach ($modules as $module) {
         $parts = explode('\\', get_class($module));
         $modName = array_shift($parts);
         if (!empty($modulesAllowedToScan) && !in_array($modName, $modulesAllowedToScan)) {
             continue;
         }
         $ref = new ReflectionClass($module);
         $dir = dirname($ref->getFileName());
         foreach ($scanner->scan($dir) as $class) {
             $classesToParse[] = $class;
         }
     }
     $parsedConfig = $parser->parse($classesToParse);
     $event->getConfigListener()->setMergedConfig(array_replace_recursive($parsedConfig, $config));
 }

作者:xemloc    项目:HumusMv   
/**
  * Creates and returns the module manager
  *
  * Instantiates the default module listeners, providing them configuration
  * from the "module_listener_options" key of the ApplicationConfig
  * service. Also sets the default config glob path.
  *
  * Module manager is instantiated and provided with an EventManager, to which
  * the default listener aggregate is attached. The ModuleEvent is also created
  * and attached to the module manager.
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return ModuleManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     if (!$serviceLocator->has('ServiceListener')) {
         $serviceLocator->setFactory('ServiceListener', 'HumusMvc\\Service\\ServiceListenerFactory');
     }
     if (!$serviceLocator->has('Zf1MvcListener')) {
         $serviceLocator->setFactory('Zf1MvcListener', 'HumusMvc\\Service\\Zf1MvcListenerFactory');
     }
     $configuration = $serviceLocator->get('ApplicationConfig');
     $listenerOptions = new ListenerOptions($configuration['module_listener_options']);
     $defaultListeners = new DefaultListenerAggregate($listenerOptions);
     $serviceListener = $serviceLocator->get('ServiceListener');
     $serviceListener->addServiceManager($serviceLocator, 'service_manager', 'Zend\\ModuleManager\\Feature\\ServiceProviderInterface', 'getServiceConfig');
     $serviceListener->addServiceManager('ViewHelperManager', 'view_helpers', 'Zend\\ModuleManager\\Feature\\ViewHelperProviderInterface', 'getViewHelperConfig');
     $serviceListener->addServiceManager('ActionHelperManager', 'action_helpers', 'HumusMvc\\ModuleManager\\Feature\\ActionHelperProviderInterface', 'getActionHelperConfig');
     $events = $serviceLocator->get('EventManager');
     $events->attach($defaultListeners);
     $events->attach($serviceListener);
     $sharedEvents = $events->getSharedManager();
     $sharedEvents->attach('HumusMvc\\Application', 'bootstrap', new LocaleListener());
     $moduleEvent = new ModuleEvent();
     $moduleEvent->setParam('ServiceManager', $serviceLocator);
     $moduleManager = new ModuleManager($configuration['modules'], $events);
     $moduleManager->setEvent($moduleEvent);
     return $moduleManager;
 }

作者:hickeroa    项目:zf2-route-inheritanc   
/**
  * @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);
 }

作者:pradeep-sanjay    项目:doctrine-extension   
public function onMergeConfig(ModuleEvent $e)
 {
     $configListener = $e->getConfigListener();
     $config = $configListener->getMergedConfig(false);
     // Modify the configuration; here, we'll add Oracle Custom DQL Functions:
     if (isset($config['doctrine_extensions']['oracle_doctrine_driver_config_key'])) {
         $configKey = $config['doctrine_extensions']['oracle_doctrine_driver_config_key'];
         //Get existing map (if any) to be merged with the module map
         if (isset($config['doctrine']['configuration'][$configKey])) {
             $existingMap = $config['doctrine']['configuration'][$configKey];
         } else {
             $existingMap = array();
         }
         $config['doctrine']['configuration'][$configKey] = array_merge_recursive($existingMap, DoctrineExtensionsUtilts::getOracleDQLFunctions());
     }
     // Modify the configuration; here, we'll add MySQL Custom DQL Functions:
     if (isset($config['doctrine_extensions']['mysql_doctrine_driver_config_key'])) {
         $configKey = $config['doctrine_extensions']['mysql_doctrine_driver_config_key'];
         //Get existing map (if any) to be merged with the module map
         if (isset($config['doctrine']['configuration'][$configKey])) {
             $existingMap = $config['doctrine']['configuration'][$configKey];
         } else {
             $existingMap = array();
         }
         $config['doctrine']['configuration'][$configKey] = array_merge_recursive($existingMap, DoctrineExtensionsUtilts::getMysqlDQLFunctions());
     }
     // Pass the changed configuration back to the listener:
     $configListener->setMergedConfig($config);
 }

作者:JeoffScot    项目:dyplo   
/**
  * Creates and returns the module manager
  *
  * Instantiates the default module listeners, providing them configuration
  * from the "module_listener_options" key of the ApplicationConfig
  * service. Also sets the default config glob path.
  *
  * Module manager is instantiated and provided with an EventManager, to which
  * the default listener aggregate is attached. The ModuleEvent is also created
  * and attached to the module manager.
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return ModuleManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     if (!$serviceLocator->has('ServiceListener')) {
         $serviceLocator->setFactory('ServiceListener', 'Zend\\Mvc\\Service\\ServiceListenerFactory');
     }
     $configuration = $serviceLocator->get('ApplicationConfig');
     $listenerOptions = new ListenerOptions($configuration['module_listener_options']);
     $defaultListeners = new DefaultListenerAggregate($listenerOptions);
     $serviceListener = $serviceLocator->get('ServiceListener');
     $serviceListener->addServiceManager($serviceLocator, 'service_manager', 'Zend\\ModuleManager\\Feature\\ServiceProviderInterface', 'getServiceConfig');
     $serviceListener->addServiceManager('ControllerLoader', 'controllers', 'Zend\\ModuleManager\\Feature\\ControllerProviderInterface', 'getControllerConfig');
     $serviceListener->addServiceManager('ControllerPluginManager', 'controller_plugins', 'Zend\\ModuleManager\\Feature\\ControllerPluginProviderInterface', 'getControllerPluginConfig');
     $serviceListener->addServiceManager('ViewHelperManager', 'view_helpers', 'Zend\\ModuleManager\\Feature\\ViewHelperProviderInterface', 'getViewHelperConfig');
     $serviceListener->addServiceManager('ValidatorManager', 'validators', 'Zend\\ModuleManager\\Feature\\ValidatorProviderInterface', 'getValidatorConfig');
     $serviceListener->addServiceManager('FilterManager', 'filters', 'Zend\\ModuleManager\\Feature\\FilterProviderInterface', 'getFilterConfig');
     $serviceListener->addServiceManager('FormElementManager', 'form_elements', 'Zend\\ModuleManager\\Feature\\FormElementProviderInterface', 'getFormElementConfig');
     $serviceListener->addServiceManager('RoutePluginManager', 'route_manager', 'Zend\\ModuleManager\\Feature\\RouteProviderInterface', 'getRouteConfig');
     $serviceListener->addServiceManager('SerializerAdapterManager', 'serializers', 'Zend\\ModuleManager\\Feature\\SerializerProviderInterface', 'getSerializerConfig');
     $serviceListener->addServiceManager('HydratorManager', 'hydrators', 'Zend\\ModuleManager\\Feature\\HydratorProviderInterface', 'getHydratorConfig');
     $serviceListener->addServiceManager('InputFilterManager', 'input_filters', 'Zend\\ModuleManager\\Feature\\InputFilterProviderInterface', 'getInputFilterConfig');
     $serviceListener->addServiceManager('LogProcessorManager', 'log_processors', 'Zend\\ModuleManager\\Feature\\LogProcessorProviderInterface', 'getLogProcessorConfig');
     $serviceListener->addServiceManager('LogWriterManager', 'log_writers', 'Zend\\ModuleManager\\Feature\\LogWritersProviderInterface', 'getLogWriterConfig');
     $events = $serviceLocator->get('EventManager');
     $events->attach($defaultListeners);
     $events->attach($serviceListener);
     $moduleEvent = new ModuleEvent();
     $moduleEvent->setParam('ServiceManager', $serviceLocator);
     $moduleManager = new ModuleManager($configuration['modules'], $events);
     $moduleManager->setEvent($moduleEvent);
     return $moduleManager;
 }

作者:scottasmit    项目:zf2-orm-ap   
/**
  * Creates and returns the module manager
  *
  * Instantiates the default module listeners, providing them configuration
  * from the "module_listener_options" key of the ApplicationConfig
  * service. Also sets the default config glob path.
  *
  * Module manager is instantiated and provided with an EventManager, to which
  * the default listener aggregate is attached. The ModuleEvent is also created
  * and attached to the module manager.
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return ModuleManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     if (!$serviceLocator->has('ServiceListener')) {
         $serviceLocator->setFactory('ServiceListener', 'Console\\Service\\ServiceListenerFactory');
     }
     $configuration = $serviceLocator->get('ApplicationConfig');
     $listenerOptions = new ListenerOptions($configuration['module_listener_options']);
     $defaultListeners = new DefaultListenerAggregate($listenerOptions);
     $serviceListener = $serviceLocator->get('ServiceListener');
     $serviceListener->addServiceManager($serviceLocator, 'service_manager', 'Zend\\ModuleManager\\Feature\\ServiceProviderInterface', 'getServiceConfig');
     $serviceListener->addServiceManager('ValidatorManager', 'validators', 'Zend\\ModuleManager\\Feature\\ValidatorProviderInterface', 'getValidatorConfig');
     $serviceListener->addServiceManager('FilterManager', 'filters', 'Zend\\ModuleManager\\Feature\\FilterProviderInterface', 'getFilterConfig');
     $serviceListener->addServiceManager('SerializerAdapterManager', 'serializers', 'Zend\\ModuleManager\\Feature\\SerializerProviderInterface', 'getSerializerConfig');
     $serviceListener->addServiceManager('SerializerAdapterManager', 'serializers', 'Zend\\ModuleManager\\Feature\\SerializerProviderInterface', 'getSerializerConfig');
     $serviceListener->addServiceManager('HydratorManager', 'hydrators', 'Zend\\ModuleManager\\Feature\\HydratorProviderInterface', 'getHydratorConfig');
     $serviceListener->addServiceManager('InputFilterManager', 'input_filters', 'Zend\\ModuleManager\\Feature\\InputFilterProviderInterface', 'getInputFilterConfig');
     $events = $serviceLocator->get('EventManager');
     $events->attach($defaultListeners);
     $events->attach($serviceListener);
     $moduleEvent = new ModuleEvent();
     $moduleEvent->setParam('ServiceManager', $serviceLocator);
     $moduleManager = new ModuleManager($configuration['modules'], $events);
     $moduleManager->setEvent($moduleEvent);
     return $moduleManager;
 }

作者:gstearmi    项目:EshopVegeTabl   
/**
  * loadModule
  *
  * Check each loaded module to see if it implements LocatorRegistered. If it
  * does, we add it to an internal array for later.
  *
  * @param  ModuleEvent $e
  * @return void
  */
 public function onLoadModule(ModuleEvent $e)
 {
     if (!$e->getModule() instanceof LocatorRegisteredInterface) {
         return;
     }
     $this->modules[] = $e->getModule();
 }

作者:htam26    项目:zendskeleto   
public function onMergeConfig(\Zend\ModuleManager\ModuleEvent $event)
 {
     $configListener = $event->getConfigListener();
     $config = $configListener->getMergedConfig(false);
     //        echo '<pe>';
     //        print_r($config);
     //        echo '</pre>';
 }

作者:raZ3    项目:zf   
/**
  * @param ModuleEvent $e
  * @eturn void
  */
 public function __invoke(ModuleEvent $e)
 {
     $module = $e->getModule();
     if (!$module instanceof InitProviderInterface && !method_exists($module, 'init')) {
         return;
     }
     $module->init($e->getTarget());
 }

作者:trongl    项目:zend-   
public function onMergeConfig(ModuleEvent $moduleEvent)
 {
     $configListener = $moduleEvent->getConfigListener();
     $config = $configListener->getMergedConfig(false);
     // echo "<pre style='font-weight:bold'>";
     // print_r($config['controllers']);
     // echo "</pre>";
 }

作者:phpa    项目:phpab-modul   
/**
  * Called when the modules are loaded.
  *
  * @param ModuleEvent $event
  */
 public function onLoadModulesPost(ModuleEvent $event)
 {
     /** @var ServiceManager $serviceManager */
     $serviceManager = $event->getParam('ServiceManager');
     /** @var EngineInterface $engine */
     $engine = $serviceManager->get('phpab.engine');
     $engine->start();
 }

作者:Baf    项目:Zend-For   
/**
  * @param  ModuleEvent $e
  * @return void
  */
 public function __invoke(ModuleEvent $e)
 {
     $module = $e->getModule();
     if (!$module instanceof AutoloaderProviderInterface && !method_exists($module, 'getAutoloaderConfig')) {
         return;
     }
     $autoloaderConfig = $module->getAutoloaderConfig();
     AutoloaderFactory::factory($autoloaderConfig);
 }

作者:karnuri    项目:zf2-turtoria   
/**
  * @param  ModuleEvent $e
  * @return object|false False if module class does not exist
  */
 public function __invoke(ModuleEvent $e)
 {
     $moduleName = $e->getModuleName();
     $class = $moduleName . '\\Module';
     if (!class_exists($class)) {
         return false;
     }
     return new $class();
 }

作者:pnaq5    项目:zf2dem   
public function testModuleResolverListenerCanResolveModuleClasses()
 {
     $moduleResolver = new ModuleResolverListener();
     $e = new ModuleEvent();
     $e->setModuleName('ListenerTestModule');
     $this->assertInstanceOf('ListenerTestModule\\Module', $moduleResolver($e));
     $e->setModuleName('DoesNotExist');
     $this->assertFalse($moduleResolver($e));
 }

作者:coolm    项目:doctrine-or   
/**
  * @param ModuleEvent $e
  */
 public function onPostLoadModules(ModuleEvent $e)
 {
     $configListener = $e->getConfigListener();
     $config = $configListener->getMergedConfig(false);
     if (isset($config['doctrine']['configuration']['orm_default']['proxy_dir']) && isset($config['doctrine']['configuration']['orm_default']['proxy_namespace'])) {
         // We need to register here manualy. Please see http://www.doctrine-project.org/jira/browse/DDC-1698
         ProxyAutoloader::register($config['doctrine']['configuration']['orm_default']['proxy_dir'], $config['doctrine']['configuration']['orm_default']['proxy_namespace']);
     }
 }

作者:abacaphilia    项目:zend-eventmanager-pluginmanage   
public function testInitRegistersPluginManager()
 {
     $event = new ModuleEvent();
     $event->setParam('ServiceManager', $this->serviceLocator);
     $this->moduleManager->expects(self::any())->method('getEvent')->willReturn($event);
     $this->serviceLocator->setService('ServiceListener', $this->serviceListener);
     $this->serviceListener->expects(self::atLeastOnce())->method('addServiceManager');
     $actual = $this->sut->init($this->moduleManager);
     self::assertNull($actual);
 }

作者:paulusov    项目:VuFind-2.   
public function onMergeConfig(ModuleEvent $e)
 {
     $configListener = $e->getConfigListener();
     $config = $configListener->getMergedConfig(false);
     // Modify the configuration; here, we'll remove a specific key:
     if (isset($config['service_manager']['invokables']['VuFind\\Search'])) {
         unset($config['service_manager']['invokables']['VuFind\\Search']);
     }
     // Pass the changed configuration back to the listener:
     $configListener->setMergedConfig($config);
 }

作者:Ineanc    项目:zf2-lazy-loading-modul   
/**
  * Pass self to the ModuleEvent object early so everyone has access. 
  * 
  * @param ModuleEvent $e 
  * @return ConfigListener
  */
 public function loadModulesPre(ModuleEvent $e)
 {
     if ($this->getOptions()->getConfigCacheEnabled()) {
         $this->getOptions()->setConfigCacheKey(implode('.', $e->getTarget()->getModules()) . '.' . $this->getOptions()->getConfigCacheKey());
         if ($this->hasCachedConfig()) {
             $this->skipConfig = true;
             $this->setMergedConfig($this->getCachedConfig());
         }
     }
     return parent::loadModulesPre($e);
 }

作者:JPG-Consultin    项目:LocaleManager-OL   
public function onMergeConfig(ModuleEvent $e)
 {
     $configListener = $e->getConfigListener();
     $config = $configListener->getMergedConfig(false);
     // Make sure the router class is set to LocaleAwareTreeRouteStack
     if (!Console::isConsole()) {
         $config['router']['router_class'] = 'LocaleManager\\Router\\Http\\LocaleTreeRouteStack';
     }
     // Pass the changed configuration back to the listener:
     $configListener->setMergedConfig($config);
 }


问题


面经


文章

微信
公众号

扫码关注公众号