本文整理匯總了PHP中Zend\ModuleManager\ModuleManager類的典型用法代碼示例。如果您正苦於以下問題:PHP ModuleManager類的具體用法?PHP ModuleManager怎麽用?PHP ModuleManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ModuleManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
/**
* Wird bei der Initialisierung des Moduls aufgerufen
* @param \Zend\ModuleManager\ModuleManager $moduleManager
*/
public function init(\Zend\ModuleManager\ModuleManager $moduleManager)
{
$sharedManager = $moduleManager->getEventManager()->getSharedManager();
$sharedManager->attach('DragonJsonServer\\Service\\Server', 'Request', function (\DragonJsonServer\Event\Request $eventRequest) {
$request = $eventRequest->getRequest();
$method = $request->getMethod();
$securitytokens = $this->getServiceManager()->get('Config')['dragonjsonserversecuritytoken']['securitytokens'];
foreach ($securitytokens as $namespace => $securitytoken) {
if (substr($method, 0, strlen($namespace . '.')) != $namespace . '.') {
continue;
}
if ($request->getParam('securitytoken') != $securitytoken) {
throw new \DragonJsonServer\Exception('invalid securitytoken', ['namespace' => $namespace]);
}
}
});
$sharedManager->attach('DragonJsonServer\\Service\\Server', 'Servicemap', function (\DragonJsonServer\Event\Servicemap $eventServicemap) {
$securitytokens = $this->getServiceManager()->get('Config')['dragonjsonserversecuritytoken']['securitytokens'];
foreach ($eventServicemap->getServicemap()->getServices() as $method => $service) {
foreach ($securitytokens as $namespace => $securitytoken) {
$namespace .= '.';
if (substr($method, 0, strlen($namespace)) != $namespace) {
continue;
}
$service->addParams([['type' => 'string', 'name' => 'securitytoken', 'optional' => false]]);
}
}
});
}
示例2: init
/**
* Module init
*
* @param ModuleManager $moduleManager
*/
public function init(ModuleManager $moduleManager)
{
$sm = $moduleManager->getEvent()->getParam('ServiceManager');
$serviceListener = $sm->get('ServiceListener');
$serviceListener->addServiceManager('ZfApigilityDoctrineQueryProviderManager', 'zf-apigility-doctrine-query-provider', 'ZF\\Apigility\\Doctrine\\Server\\Query\\Provider\\QueryProviderInterface', 'getZfApigilityDoctrineQueryProviderConfig');
$serviceListener->addServiceManager('ZfApigilityDoctrineQueryCreateFilterManager', 'zf-apigility-doctrine-query-create-filter', 'ZF\\Apigility\\Doctrine\\Server\\Query\\CreateFilter\\QueryCreateFilterInterface', 'getZfApigilityDoctrineQueryCreateFilterConfig');
}
示例3: init
public function init(ModuleManager $moduleManager)
{
$sharedEvents = $moduleManager->getEventManager()->getSharedManager();
// $sharedEvents->attach("Zend\Mvc\Controller\AbstractActionController",
// MvcEvent::EVENT_DISPATCH,
// array($this,'validaAuth'),100);
}
示例4: init
/**
* Llamo a este método cuando se llama al módulo
* @param \Zend\ModuleManager\ModuleManager $moduleManager
*/
public function init(ModuleManager $moduleManager)
{
$sharedEvents = $moduleManager->getEventManager()->getSharedManager();
$sharedEvents->attach(__NAMESPACE__, 'dispatch', function ($e) {
$controller = $e->getTarget();
}, 100);
}
示例5: init
/**
* Register a specification for the InputFilterManager with the ServiceListener.
*
* @param \Zend\ModuleManager\ModuleManager $moduleManager
* @return void
*/
public function init($moduleManager)
{
$event = $moduleManager->getEvent();
$container = $event->getParam('ServiceManager');
$serviceListener = $container->get('ServiceListener');
$serviceListener->addServiceManager('InputFilterManager', 'input_filters', 'Zend\\ModuleManager\\Feature\\InputFilterProviderInterface', 'getInputFilterConfig');
}
示例6: init
public function init(ModuleManager $moduleManager)
{
$moduleManager->getEventManager()->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, array($this, 'setOptions'), 1010);
$moduleManager->getEventManager()->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, array($this, 'addLocaleToRoutes'), 1000);
// a little hacky but it avoid rewriting of many codes
$moduleManager->getEventManager()->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, array($this, 'overrideViewHelperUrl'));
}
示例7: init
/**
* Wird bei der Initialisierung des Moduls aufgerufen
* @param \Zend\ModuleManager\ModuleManager $moduleManager
*/
public function init(\Zend\ModuleManager\ModuleManager $moduleManager)
{
$sharedManager = $moduleManager->getEventManager()->getSharedManager();
$sharedManager->attach('DragonJsonServer\\Service\\Server', 'Response', function (\DragonJsonServer\Event\Response $eventResponse) {
$this->getServiceManager()->get('\\DragonJsonServerRequestlog\\Service\\Requestlog')->createRequestlog($eventResponse->getRequest(), $eventResponse->getResponse());
});
}
示例8: init
public function init(ModuleManager $moduleManager)
{
$sm = $moduleManager->getEvent()->getParam('ServiceManager');
/* @var $serviceListener \Zend\ModuleManager\Listener\ServiceListener */
$serviceListener = $sm->get('ServiceListener');
$serviceListener->addServiceManager('FormatterManager', 'formatter_manager', 'Formatter\\FormatterManager\\FormatterManager', 'getFormatterPluginConfig');
}
示例9: init
public function init(ModuleManager $moduleManager)
{
$serviceManager = $moduleManager->getEvent()->getParam('ServiceManager');
$serviceListener = $serviceManager->get('ServiceListener');
$serviceListener->addServiceManager('ZF\\Doctrine\\ORM\\QueryBuilder\\Filter\\Service\\FilterManager', 'zf-doctrine-orm-querybuilder-filter', 'ZF\\Doctrine\\QueryBuilder\\Filter\\FilterInterface', 'getDoctrineORMQueryBuilderFilterConfig');
$serviceListener->addServiceManager('ZF\\Doctrine\\ORM\\QueryBuilder\\OrderBy\\Service\\OrderByManager', 'zf-doctrine-orm-querybuilder-orderby', 'ZF\\Doctrine\\QueryBuilder\\OrderBy\\OrderByInterface', 'getDoctrineORMQueryBuilderOrderByConfig');
}
示例10: createService
/**
* 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 Service Manager
*
* @return ModuleManager
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$moduleCollection = new ModuleCollection();
$modules = $moduleCollection->getModules();
$array = array();
$autoloader = AutoloaderFactory::getRegisteredAutoloader(AutoloaderFactory::STANDARD_AUTOLOADER);
foreach ($modules as $module) {
$array[] = $module->getName();
$path = GC_APPLICATION_PATH . '/library/Modules/' . $module->getName();
if (file_exists($path) === false) {
$path = GC_APPLICATION_PATH . '/extensions/Modules/' . $module->getName();
}
$autoloader->registerNamespace($module->getName(), $path);
}
$autoloader->register();
$application = $serviceLocator->get('Application');
$configuration = $serviceLocator->get('ApplicationConfig');
$configuration['module_listener_options']['module_paths'] = array('./library/Modules', './extensions/Modules');
$listenerOptions = new Listener\ListenerOptions($configuration['module_listener_options']);
$defaultListeners = new Listener\DefaultListenerAggregate($listenerOptions);
$serviceListener = new Listener\ServiceListener($serviceLocator);
$this->prepareServices($serviceListener, $serviceLocator);
$moduleManager = new ModuleManager($array, $application->getEventManager());
$moduleManager->getEventManager()->attachAggregate($defaultListeners);
$moduleManager->getEventManager()->attachAggregate($serviceListener);
$moduleManager->loadModules();
$config = $moduleManager->getEvent()->getConfigListener()->getMergedConfig(false);
$this->prepareConfig($serviceLocator, $config);
foreach ($moduleManager->getLoadedModules() as $module) {
if (method_exists($module, 'onBootstrap')) {
$module->onBootstrap($application->getMvcEvent());
}
}
return $moduleManager;
}
示例11: init
/**
* Wird bei der Initialisierung des Moduls aufgerufen
* @param \Zend\ModuleManager\ModuleManager $moduleManager
*/
public function init(\Zend\ModuleManager\ModuleManager $moduleManager)
{
$sharedManager = $moduleManager->getEventManager()->getSharedManager();
$sharedManager->attach('DragonJsonServer\\Service\\Clientmessages', 'Clientmessages', function (\DragonJsonServer\Event\Clientmessages $eventClientmessages) {
$serviceManager = $this->getServiceManager();
$serviceAllianceavatar = $serviceManager->get('\\DragonJsonServerAlliance\\Service\\Allianceavatar');
$allianceavatar = $serviceAllianceavatar->getAllianceavatar();
if (!isset($allianceavatar)) {
$avatar = $serviceManager->get('\\DragonJsonServerAvatar\\Service\\Avatar')->getAvatar();
if (!isset($avatar)) {
return;
}
$allianceavatar = $serviceAllianceavatar->getAllianceavatarByAvatar($avatar, false);
if (!isset($allianceavatar)) {
return;
}
}
$allianceclientmessages = $serviceManager->get('\\DragonJsonServerAllianceclientmessage\\Service\\Allianceclientmessage')->getAllianceclientmessagesByAllianceIdAndEventClientmessages($allianceavatar->getAllianceId(), $eventClientmessages);
$serviceClientmessages = $serviceManager->get('\\DragonJsonServer\\Service\\Clientmessages');
foreach ($allianceclientmessages as $allianceclientmessage) {
$serviceClientmessages->addClientmessage($allianceclientmessage->getKey(), $allianceclientmessage->getData());
}
});
$sharedManager->attach('DragonJsonServerAlliance\\Service\\Alliance', 'RemoveAlliance', function (\DragonJsonServerAlliance\Event\RemoveAlliance $eventRemoveAlliance) {
$alliance = $eventRemoveAlliance->getAlliance();
$this->getServiceManager()->get('\\DragonJsonServerAllianceclientmessage\\Service\\Allianceclientmessage')->removeAllianceclientmessagesByAllianceId($alliance->getAllianceId());
});
}
示例12: init
/**
* @param \Zend\ModuleManager\ModuleManager $mm
*/
public function init(\Zend\ModuleManager\ModuleManager $mm)
{
$mm->getEventManager()->getSharedManager()->attach(__NAMESPACE__, 'dispatch', function ($e) {
/** @var MvcEvent $e */
$e->getTarget()->layout('layout/admin');
}, 100);
}
示例13: 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);
}
});
}
示例14: init
/**
* Register a specification for the FormElementManager with the ServiceListener.
*
* @param \Zend\ModuleManager\ModuleManager $moduleManager
* @return void
*/
public function init($moduleManager)
{
$event = $moduleManager->getEvent();
$container = $event->getParam('ServiceManager');
$serviceListener = $container->get('ServiceListener');
$serviceListener->addServiceManager('FormElementManager', 'form_elements', 'Zend\\ModuleManager\\Feature\\FormElementProviderInterface', 'getFormElementConfig');
}
示例15: createService
/**
* 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;
}