作者:dragonproject
项目:dragonjsonserversecuritytoke
/**
* 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]]);
}
}
});
}
作者:API-Skeleton
项目:zf-apigility-doctrin
/**
* 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');
}
作者:abelclope
项目:ZF2-Intermediario-com-ac
public function init(ModuleManager $moduleManager)
{
$sharedEvents = $moduleManager->getEventManager()->getSharedManager();
// $sharedEvents->attach("Zend\Mvc\Controller\AbstractActionController",
// MvcEvent::EVENT_DISPATCH,
// array($this,'validaAuth'),100);
}
作者:rodrigogk8
项目:djm
/**
* 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);
}
作者:zendframewor
项目:zend-inputfilte
/**
* 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');
}
作者:joacu
项目:libra-local
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'));
}
作者:dragonproject
项目:dragonjsonserverrequestlo
/**
* 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());
});
}
作者:gianar
项目:zf2-formatte
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');
}
作者:api-skeleton
项目:zf-doctrine-orm-querybuilde
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');
}
作者:gotcm
项目:gotcm
/**
* 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;
}
作者:dragonproject
项目:dragonjsonserverallianceclientmessag
/**
* 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());
});
}
作者:kokspflanz
项目:PServerAdminStatisti
/**
* @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);
}
作者:Ellipizl
项目:LosDomai
/**
* 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);
}
});
}
作者:zendframewor
项目:zend-for
/**
* 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');
}
作者: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;
}
作者:localhein
项目:zend-hydrato
/**
* Register a specification for the HydratorManager 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('HydratorManager', 'hydrators', 'Zend\\ModuleManager\\Feature\\HydratorProviderInterface', 'getHydratorConfig');
}
作者: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;
}
作者:froschdesig
项目:zend-i18
/**
* Register a specification for the TranslatorPluginManager 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('TranslatorPluginManager', 'translator_plugins', 'Zend\\ModuleManager\\Feature\\TranslatorPluginProviderInterface', 'getTranslatorPluginConfig');
}
作者:dragonproject
项目:dragonjsonserveravatarmessag
/**
* 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();
if (!$serviceManager->get('Config')['dragonjsonserveravatarmessage']['clientmessages']) {
return;
}
$avatar = $serviceManager->get('\\DragonJsonServerAvatar\\Service\\Avatar')->getAvatar();
if (null === $avatar) {
return;
}
$serviceAvatarmessage = $serviceManager->get('\\DragonJsonServerAvatarmessage\\Service\\Avatarmessage');
$avatarmessages = $serviceAvatarmessage->getAvatarmessagesByEventClientmessages($avatar, $eventClientmessages);
if (0 == count($avatarmessages)) {
return;
}
$avatarmessages = $serviceManager->get('\\DragonJsonServerDoctrine\\Service\\Doctrine')->toArray($avatarmessages);
$serviceManager->get('\\DragonJsonServer\\Service\\Clientmessages')->addClientmessage('avatarmassages', $avatarmessages);
});
$sharedManager->attach('DragonJsonServerAvatar\\Service\\Avatar', 'RemoveAvatar', function (\DragonJsonServerAvatar\Event\RemoveAvatar $eventRemoveAvatar) {
$serviceAvatarmessage = $this->getServiceManager()->get('\\DragonJsonServerAvatarmessage\\Service\\Avatarmessage');
$serviceAvatarmessage->removeAvatarmessagesByAvatarId($eventRemoveAvatar->getAvatar()->getAvatarId());
});
}
作者:superdweebi
项目:doctrine-extensions-modul
public function init(ModuleManager $moduleManager)
{
$eventManager = $moduleManager->getEventManager();
$sharedEventManager = $eventManager->getSharedManager();
$eventManager->attach(ModuleEvent::EVENT_MERGE_CONFIG, array($this, 'onConfigMerge'), 1);
$sharedEventManager->attach('doctrine', 'loadCli.post', array($this, 'initializeConsole'));
}