本文整理汇总了PHP中Zend\EventManager\EventInterface::getApplication方法的典型用法代码示例。如果您正苦于以下问题:PHP EventInterface::getApplication方法的具体用法?PHP EventInterface::getApplication怎么用?PHP EventInterface::getApplication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\EventManager\EventInterface
的用法示例。
在下文中一共展示了EventInterface::getApplication方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBootstrap
public function onBootstrap(EventInterface $e)
{
$this->oServiceLocator = $e->getApplication()->getServiceManager();
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
}
示例2: onBootstrap
public function onBootstrap(\Zend\EventManager\EventInterface $e)
{
/* @var $e \Zend\Mvc\MvcEvent */
$eventManager = $e->getApplication()->getEventManager();
$sm = $e->getApplication()->getServiceManager();
$translator = $sm->get('MvcTranslator');
\Zend\Validator\AbstractValidator::setDefaultTranslator($translator);
}
示例3: onBootstrap
/**
* Attach the module to the main MVC event
*
* @param MvcEvent $e
*/
public function onBootstrap(EventInterface $event)
{
$serviceManager = $event->getApplication()->getServiceManager();
$this->config = $serviceManager->get('config');
$eventManager = $event->getApplication()->getEventManager();
$eventManager->attach(MvcEvent::EVENT_DISPATCH, array($this, 'preDispatch'), 100);
$serviceManager->setService('targetConfig', new ArrayObject($this->config['zsapi']['target']));
}
示例4: onBootstrap
public function onBootstrap(EventInterface $e)
{
$e->getApplication()->getServiceManager()->get('translator');
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
$this->initConfig($e);
}
示例5: onBootstrap
/**
* {@inheritdoc}
*/
public function onBootstrap(EventInterface $e)
{
$this->services = $e->getApplication()->getServiceManager();
$eventManager = $e->getApplication()->getEventManager();
$eventManager->attach(MvcEvent::EVENT_DISPATCH, [$this, 'onDispatch']);
$eventManager->attach(MvcEvent::EVENT_RENDER, [$this, 'onRender']);
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
}
示例6: onBootstrap
public function onBootstrap(EventInterface $e)
{
$eventManager = $e->getApplication()->getEventManager();
$serviceManager = $e->getApplication()->getServiceManager();
// Listener have only sense when request is via http.
if (!Console::isConsole()) {
$eventManager->attach(new AssetRouteListener());
}
}
示例7: onBootstrap
/**
* @param EventInterface $e
*
* @return array|void
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
*/
public function onBootstrap(EventInterface $e)
{
/** @var MvcEvent $e */
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
$sl = $e->getApplication()->getServiceManager();
EntityManagerFactory::setDefaultServiceLocator($sl);
}
示例8: onBootstrap
public function onBootstrap(EventInterface $e)
{
/* @var $e MvcEvent */
$eventManager = $e->getApplication()->getEventManager();
$services = $e->getApplication()->getServiceManager();
$sharedManager = $eventManager->getSharedManager();
$createJobListener = new \Organizations\Acl\Listener\CheckJobCreatePermissionListener();
$createJobListener->attachShared($sharedManager);
}
示例9: onBootstrap
/**
* @param EventInterface $event
*
* @return array|void
*/
public function onBootstrap(EventInterface $event)
{
/** @var \Zend\Mvc\MvcEvent $event */
/** @var Service\SessionGuard $service */
$service = $event->getApplication()->getServiceManager()->get('DmMailerAdmin\\Service\\SessionGuard');
/** @var \Zend\EventManager\EventManager $entityManager */
$entityManager = $event->getApplication()->getEventManager();
$entityManager->attachAggregate($service);
}
示例10: onBootstrap
/**
* @param EventInterface $e
*
* @return array|void
*
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
*/
public function onBootstrap(EventInterface $e)
{
/** @var MvcEvent $e */
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
/** @var WorkflowDispatchListener $injectWorkflowListener */
$injectWorkflowListener = $e->getApplication()->getServiceManager()->get(WorkflowDispatchListener::class);
$eventManager->attach($injectWorkflowListener);
}
示例11: onBootstrap
public function onBootstrap(EventInterface $e)
{
$application = $e->getTarget();
$eventManager = $application->getEventManager();
$services = $application->getServiceManager();
$services->get('Server');
$e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\\Mvc\\Controller\\AbstractController', 'dispatch', function ($e) {
$controller = $e->getTarget();
$controllerClass = get_class($controller);
$moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
$config = $e->getApplication()->getServiceManager()->get('config');
if (isset($config['module_layouts'][$moduleNamespace])) {
$controller->layout($config['module_layouts'][$moduleNamespace]);
}
}, 100);
$eventManager->attach('route', function ($event) {
$sm = $event->getApplication()->getServiceManager();
$config = $event->getApplication()->getServiceManager()->get('Config');
$localesConfig = $config['locales'];
$locales = $localesConfig['list'];
$locale = $event->getRouteMatch()->getParam('locale', null);
if (empty($locale)) {
$locale = isset($_COOKIE['locale']) ? $_COOKIE['locale'] : $localesConfig['default']['code'];
}
if (in_array($locale, array_keys($locales))) {
$locale = $locales[$locale]['code'];
} else {
$locale = $localesConfig['default']['code'];
}
$translator = $sm->get('translator');
$translator->setLocale($locale);
$httpServer = "";
if (isset($_SERVER['HTTP_HOST'])) {
$httpServer = $_SERVER['HTTP_HOST'];
}
setcookie('locale', $locale, time() + 3600, '/', $httpServer);
}, -10);
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
$eventManager->attach('dispatch.error', function ($event) use($services) {
$event->getResult()->setTerminal(TRUE);
$exception = $event->getResult()->exception;
$error = $event->getError();
if (!$exception && !$error) {
return;
}
$service = $services->get('Likerow\\ErrorHandler');
if ($exception) {
$service->logException($exception, $services->get('Mail'));
}
if ($error) {
$service->logError('Dispatch ERROR: ' . $error, $services->get('Mail'));
}
});
}
示例12: onBootstrap
/**
* Listen to the bootstrap event
*
* @param EventInterface $e
*
* @return void
*/
public function onBootstrap(EventInterface $e)
{
/** @var MvcEvent $e */
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
// add layout listener
$eventManager->attachAggregate(new LayoutListener(array('header', 'footer')));
// configure session
$e->getApplication()->getServiceManager()->get('Session\\Config');
}
示例13: onBootstrap
/**
* @param EventInterface $e
*
* @return array|void
*
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
*/
public function onBootstrap(EventInterface $e)
{
/** @var MvcEvent $e */
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
/** @var Workflow $workflowService */
$workflowService = $e->getApplication()->getServiceManager()->get(Workflow::class);
$listener = $e->getApplication()->getServiceManager()->get(InjectTypeResolver::class);
$workflowService->getEventManager()->attach($listener);
}
示例14: onBootstrap
/**
* Listen to the bootstrap event
*
* @return array
*/
public function onBootstrap(EventInterface $e)
{
// add route listener
$e->getApplication()->getEventManager()->attachAggregate(new UserListener());
// set service locator
$this->serviceLocator = $e->getApplication()->getServiceManager();
// get shared event manager
$sharedEventManager = $this->serviceLocator->get('SharedEventManager');
// add form event
$sharedEventManager->attach('User\\Service\\UserService', 'set-user-form', array($this, 'onFormSet'));
}
示例15: onBootstrap
/**
* @param EventInterface $e
*
* @return array|void
*
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
*/
public function onBootstrap(EventInterface $e)
{
/** @var MvcEvent $e */
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
$sm = $e->getApplication()->getServiceManager();
/** @var EntryIdResolver $entryIdResolver */
$entryIdResolver = $sm->get(EntryIdResolver::class);
$eventManager->attach($entryIdResolver);
}