當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EventInterface::getApplication方法代碼示例

本文整理匯總了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);
 }
開發者ID:creativewild,項目名稱:TS3UI,代碼行數:7,代碼來源:Module.php

示例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);
 }
開發者ID:bioub,項目名稱:Formation_ZF2_Adista_201602,代碼行數:8,代碼來源:Module.php

示例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']));
 }
開發者ID:Karl-Dawson,項目名稱:ZendServerWebApiModule,代碼行數:13,代碼來源:Module.php

示例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);
 }
開發者ID:sebaxplace,項目名稱:skilla-local,代碼行數:8,代碼來源:Module.php

示例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);
 }
開發者ID:jkhaled,項目名稱:LearnZF2,代碼行數:12,代碼來源:Module.php

示例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());
     }
 }
開發者ID:shadowfax,項目名稱:zf2-asset-manager,代碼行數:9,代碼來源:Module.php

示例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);
 }
開發者ID:old-town,項目名稱:workflow-doctrine-zf2,代碼行數:15,代碼來源:Module.php

示例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);
 }
開發者ID:utrenkner,項目名稱:YAWIK,代碼行數:9,代碼來源:Module.php

示例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);
 }
開發者ID:peteraba,項目名稱:dm-maileradmin,代碼行數:14,代碼來源:Module.php

示例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);
 }
開發者ID:old-town,項目名稱:workflow-zf2-engine,代碼行數:17,代碼來源:Module.php

示例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'));
         }
     });
 }
開發者ID:likerow,項目名稱:edutek,代碼行數:55,代碼來源:Module.php

示例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');
 }
開發者ID:samsonasik,項目名稱:zf2rapid-skeleton,代碼行數:18,代碼來源:Module.php

示例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);
 }
開發者ID:old-town,項目名稱:workflow-zf2-service,代碼行數:18,代碼來源:Module.php

示例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'));
 }
開發者ID:andreaszobl,項目名稱:software,代碼行數:16,代碼來源:Module.php

示例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);
 }
開發者ID:old-town,項目名稱:workflow-zf2-toolkit,代碼行數:18,代碼來源:Module.php


注:本文中的Zend\EventManager\EventInterface::getApplication方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。