本文整理汇总了PHP中Zend\ModuleManager\ModuleEvent::getConfigListener方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleEvent::getConfigListener方法的具体用法?PHP ModuleEvent::getConfigListener怎么用?PHP ModuleEvent::getConfigListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\ModuleManager\ModuleEvent
的用法示例。
在下文中一共展示了ModuleEvent::getConfigListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onMergeConfig
/**
* @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));
}
示例2: 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);
}
示例3: 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);
}
示例4: onMergeConfig
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);
}
示例5: onMergeConfig
/**
*
* @param ModuleEvent $event
*/
public function onMergeConfig(ModuleEvent $event)
{
$config = $event->getConfigListener()->getMergedConfig(false);
$modules = $event->getTarget()->getLoadedModules();
foreach ($modules as $module) {
$ref = new ReflectionClass($module);
$dir = dirname($ref->getFileName()) . '/view';
if (!is_dir($dir)) {
continue;
}
if (!isset($config['view_manager']['template_path_stack'])) {
$config['view_manager']['template_path_stack'] = array();
}
$config['view_manager']['template_path_stack'][] = $dir;
}
$event->getConfigListener()->setMergedConfig($config);
}
示例6: onMergeConfig
public function onMergeConfig(\Zend\ModuleManager\ModuleEvent $event)
{
$configListener = $event->getConfigListener();
$config = $configListener->getMergedConfig(false);
// echo '<pe>';
// print_r($config);
// echo '</pre>';
}
示例7: onMergeConfig
public function onMergeConfig(ModuleEvent $moduleEvent)
{
$configListener = $moduleEvent->getConfigListener();
$config = $configListener->getMergedConfig(false);
// echo "<pre style='font-weight:bold'>";
// print_r($config['controllers']);
// echo "</pre>";
}
示例8: onPostLoadModules
/**
* @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']);
}
}
示例9: onMergeConfig
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);
}
示例10: onMergeConfig
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);
}
示例11: onLoadModulesPost
/**
* @param ModuleEvent $e
*/
public function onLoadModulesPost(ModuleEvent $e)
{
$appConfig = $this->serviceLocator->getServiceLocator()->get('ApplicationConfig');
$extraConfig = array();
if (isset($appConfig['framework']['app_config'])) {
$extraConfig = Config::load($appConfig['framework']['app_config']);
}
// env config
if (isset($appConfig['framework']['env_key'])) {
$env = getenv($appConfig['framework']['env_key']);
if ($env) {
$filename = 'config/env/' . $env . '.yml';
if (is_file($filename)) {
$envConfig = Config::load($filename);
$extraConfig = array_replace_recursive($extraConfig, $envConfig);
}
}
}
$config = ArrayUtils::merge($e->getConfigListener()->getMergedConfig(false), $extraConfig);
$e->getConfigListener()->setMergedConfig($config);
}
示例12: onMergeConfig
/**
* Override ZF\OAuth2\Service\OAuth2Server service
*
* If the ZF\OAuth2\Service\OAuth2Server is defined, and set to the
* default, override it with the NamedOAuth2ServerFactory.
*
* @param ModuleEvent $e
*/
public function onMergeConfig(ModuleEvent $e)
{
$configListener = $e->getConfigListener();
$config = $configListener->getMergedConfig(false);
$service = 'ZF\\OAuth2\\Service\\OAuth2Server';
$default = 'ZF\\OAuth2\\Factory\\OAuth2ServerFactory';
if (!isset($config['service_manager']['factories'][$service]) || $config['service_manager']['factories'][$service] !== $default) {
return;
}
$config['service_manager']['factories'][$service] = __NAMESPACE__ . '\\Factory\\NamedOAuth2ServerFactory';
$configListener->setMergedConfig($config);
}
示例13: onMergeConfig
/**
*
* @param ModuleEvent $event
*/
public function onMergeConfig(ModuleEvent $event)
{
$config = $event->getConfigListener()->getMergedConfig(false);
$modules = $event->getTarget()->getLoadedModules();
foreach ($modules as $module) {
$ref = new ReflectionClass($module);
$dir = dirname($ref->getFileName()) . '/language';
if (!is_dir($dir)) {
continue;
}
$iterator = new \DirectoryIterator($dir);
foreach ($iterator as $file) {
if ($file->isFile()) {
list($domain, $locale, $type) = explode('.', $file->getFilename());
if ($type === 'php') {
$type = 'phparray';
}
$config['translator']['translation_files'][] = array('type' => $type, 'filename' => $file->getPathname(), 'text_domain' => $domain, 'locale' => $locale);
}
}
}
$event->getConfigListener()->setMergedConfig($config);
}
示例14: onMergeConfig
/**
*
* @param ModuleEvent $event
*/
public function onMergeConfig(ModuleEvent $event)
{
$config = $event->getConfigListener()->getMergedConfig(false);
$modules = $event->getTarget()->getLoadedModules();
foreach ($modules as $module) {
$ref = new ReflectionClass($module);
$dir1 = dirname($ref->getFileName()) . '/Entity';
$dir2 = dirname($ref->getFileName()) . '/src/Entity';
$dirs = array_filter([$dir1, $dir2], 'is_dir');
if (count($dirs) == 0) {
continue;
}
$dir = current($dirs);
$parts = explode('\\', get_class($module));
$moduleName = array_shift($parts);
if (in_array($moduleName, $this->ignoreModules)) {
continue;
}
$driverName = strtolower($moduleName) . '_entities';
$config['doctrine']['driver']['orm_default']['drivers'][sprintf('%s\\Entity', $moduleName)] = $driverName;
$config['doctrine']['driver'][$driverName] = array('class' => 'Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver', 'cache' => 'array', 'paths' => array($dir));
}
$event->getConfigListener()->setMergedConfig($config);
}
示例15: onMergeConfig
/**
*
* @param ModuleEvent $event
*/
public function onMergeConfig(ModuleEvent $event)
{
$config = $event->getConfigListener()->getMergedConfig(false);
$resolvedControllers = $this->resolveControllers($config);
$controllerInvokables = empty($config['controllers']['invokables']) ? [] : $config['controllers']['invokables'];
$controllerFactories = empty($config['controllers']['factories']) ? [] : $config['controllers']['factories'];
$controllers = array_merge($controllerInvokables, $controllerFactories);
$injections = array();
foreach ($controllers as $controller) {
$ref = new ReflectionClass($controller);
$fileScanner = new FileScanner($ref->getFileName());
$classScanner = $fileScanner->getClass($controller);
$methods = $classScanner->getMethods();
$className = $classScanner->getName();
$controllerName = $resolvedControllers[$className];
foreach ($methods as $method) {
$methodName = $method->getName();
$actionName = preg_replace('/Action$/', '', $methodName);
foreach ($method->getParameters() as $parameter) {
$parameterScanner = $method->getParameter($parameter);
$parameterName = $parameterScanner->getName();
$class = $parameterScanner->getClass();
if ($class) {
$objectManager = $this->detectObjectManager($class, $config['mvc']['doctrine_object_injector']);
if (null !== $objectManager) {
$injections[$controllerName][$actionName][$parameterName] = [$class, $objectManager, !$parameterScanner->isOptional()];
}
} else {
$injections[$controllerName][$actionName][$parameterName] = null;
}
}
}
}
$config['mvc']['doctrine_object_injector']['injections'] = $injections;
$event->getConfigListener()->setMergedConfig($config);
}