当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::getEventManager方法代码示例

本文整理汇总了PHP中Zend\Mvc\Application::getEventManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getEventManager方法的具体用法?PHP Application::getEventManager怎么用?PHP Application::getEventManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Mvc\Application的用法示例。


在下文中一共展示了Application::getEventManager方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($name = null, array $data = array(), $dataName = '')
 {
     parent::__construct($name, $data, $dataName);
     $this->app = \Bootstrap::$app;
     $this->sm = $this->app->getServiceManager();
     $this->evm = $this->app->getEventManager();
 }
开发者ID:ebittleman,项目名称:mailgun-zf2,代码行数:7,代码来源:UnitTest.php

示例2: testOnBootstrap

 public function testOnBootstrap()
 {
     $this->assertFalse($this->app->getEventManager()->getSharedManager()->getListeners('LearnZF2I18n', MvcEvent::EVENT_DISPATCH));
     $e = new MvcEvent();
     $e->setApplication($this->app);
     $this->module->onBootstrap($e);
     $this->assertCount(1, $this->app->getEventManager()->getSharedManager()->getListeners('LearnZF2I18n', MvcEvent::EVENT_DISPATCH));
 }
开发者ID:jkhaled,项目名称:LearnZF2,代码行数:8,代码来源:ModuleTest.php

示例3: getApplication

 /**
  * @return \Zend\Mvc\Application
  */
 public function getApplication()
 {
     if ($this->spiffyApplication) {
         return $this->spiffyApplication;
     }
     Console::overrideIsConsole($this->getUseConsoleRequest());
     $this->spiffyApplication = SpiffyTest::getInstance()->getApplication();
     $events = $this->spiffyApplication->getEventManager();
     $events->detach($this->spiffyApplication->getServiceManager()->get('SendResponseListener'));
     return $this->spiffyApplication;
 }
开发者ID:svenanders,项目名称:saruser,代码行数:14,代码来源:AbstractHttpControllerTestCase.php

示例4: testUnlocatableControllerLoaderComposedOfAbstractFactory

 public function testUnlocatableControllerLoaderComposedOfAbstractFactory()
 {
     $this->setupPathController();
     $controllerLoader = $this->serviceManager->get('ControllerLoader');
     $controllerLoader->addAbstractFactory('ZendTest\\Mvc\\Controller\\TestAsset\\UnlocatableControllerLoaderAbstractFactory');
     $log = array();
     $this->application->getEventManager()->attach(MvcEvent::EVENT_DISPATCH_ERROR, function ($e) use(&$log) {
         $log['error'] = $e->getError();
     });
     $this->application->run();
     $event = $this->application->getMvcEvent();
     $dispatchListener = $this->serviceManager->get('DispatchListener');
     $return = $dispatchListener->onDispatch($event);
     $this->assertArrayHasKey('error', $log);
     $this->assertSame('error-controller-not-found', $log['error']);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:16,代码来源:DispatchListenerTest.php

示例5: testEventPropagationStatusIsClearedBetweenEventsDuringRun

 /**
  * @dataProvider eventPropagation
  */
 public function testEventPropagationStatusIsClearedBetweenEventsDuringRun($events)
 {
     $event = new MvcEvent();
     $event->setTarget($this->application);
     $event->setApplication($this->application)->setRequest($this->application->getRequest())->setResponse($this->application->getResponse())->setRouter($this->serviceManager->get('Router'));
     $event->stopPropagation(true);
     // Intentionally not calling bootstrap; setting mvc event
     $r = new ReflectionObject($this->application);
     $eventProp = $r->getProperty('event');
     $eventProp->setAccessible(true);
     $eventProp->setValue($this->application, $event);
     // Setup listeners that stop propagation, but do nothing else
     $marker = array();
     foreach ($events as $event) {
         $marker[$event] = true;
     }
     $marker = (object) $marker;
     $listener = function ($e) use($marker) {
         $marker->{$e->getName()} = $e->propagationIsStopped();
         $e->stopPropagation(true);
     };
     $this->application->getEventManager()->attach($events, $listener);
     $this->application->run();
     foreach ($events as $event) {
         $this->assertFalse($marker->{$event}, sprintf('Assertion failed for event "%s"', $event));
     }
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:30,代码来源:ApplicationTest.php

示例6: it_aborts_bootstrap_on_console

 public function it_aborts_bootstrap_on_console(MvcEvent $event, Application $application, ServiceLocatorInterface $serviceLocator, AccessListener $listener, EventManager $eventManager)
 {
     Console::overrideIsConsole(true);
     $application->getEventManager()->willReturn($eventManager);
     $serviceLocator->get(AccessListener::class)->willReturn($listener);
     $application->getServiceManager()->willReturn($serviceLocator);
     $event->getApplication()->willReturn($application);
     $listener->attach($eventManager)->shouldNotBeCalled();
     $this->onBootstrap($event);
 }
开发者ID:saeven,项目名称:zf3-circlical-user,代码行数:10,代码来源:ModuleSpec.php

示例7: getApplication

 /**
  * Get the application object
  * @return \Zend\Mvc\Application
  */
 public static function getApplication()
 {
     if (self::$application instanceof \Zend\Mvc\ApplicationInterface) {
         return self::$application;
     }
     self::$application = \Zend\Mvc\Application::init(self::getApplicationConfig());
     $oEventManager = self::$application->getEventManager();
     $oEventManager->detach(self::$application->getServiceManager()->get('SendResponseListener'));
     return self::$application;
 }
开发者ID:zf2-boiler-app,项目名称:app-test,代码行数:14,代码来源:AbstractBootstrap.php

示例8: setUp

 public function setUp()
 {
     parent::setUp();
     $this->application = \Zend\Mvc\Application::init(include TEST_APP_ROOT . '/config/application.config.php');
     $this->em = $this->application->getServiceManager()->get('doctrine.entitymanager.orm_default');
     $this->request = null;
     $this->response = null;
     $this->routeMatch = null;
     $this->viewModel = null;
     $this->event = $this->application->getMvcEvent();
     $this->eventManager = $this->application->getEventManager();
     $this->request = $this->event->getRequest();
     if (!empty($this->entities)) {
         $tool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
         foreach ($this->entities as $entity) {
             $this->doctrineEntities[] = $this->em->getClassMetadata($entity);
         }
         $tool->dropSchema($this->doctrineEntities);
         $tool->createSchema($this->doctrineEntities);
         $this->em->getConfiguration()->getResultCacheImpl()->flushAll();
         $this->em->getConfiguration()->getResultCacheImpl()->deleteAll();
     }
 }
开发者ID:dennesabing,项目名称:dx,代码行数:23,代码来源:BaseTestCase.php

示例9: getApplication

 /**
  * When application is not available, one will be initialized to respond to
  * the esi request.
  *
  * @param  Uri                   $uri
  * @return \Zend\Mvc\Application
  */
 public function getApplication(Uri $uri)
 {
     if (!$this->application instanceof Application) {
         $applicationConfig = $this->getEsiApplicationConfigProvider()->getEsiApplicationConfig($uri);
         $this->application = Application::init($applicationConfig);
         // Remove the finish listeners so response header and content is not automatically echo'd
         $this->application->getEventManager()->clearListeners(MvcEvent::EVENT_FINISH);
     }
     // The request needs to be augmented with the URI passed in
     $request = $this->application->getRequest();
     $request->setUri($uri);
     $request->setRequestUri($uri->getPath() . '?' . $uri->getQuery());
     $request->setQuery(new Parameters($uri->getQueryAsArray()));
     return $this->application;
 }
开发者ID:ACSI-IT,项目名称:ScnHttpCache,代码行数:22,代码来源:Esi.php

示例10: setApplication

 /**
  * Set the Zend\Mvc\Application and attach the event listeners.
  *
  * @param \Zend\Mvc\Application $application
  * @return ZendHttpKernel
  */
 public function setApplication(Application $application)
 {
     if ($this->application === $application) {
         // Application unchanged.
         return $this;
     }
     // Unregister from previous application.
     if ($this->application !== null) {
         // Detach from old application.
         $this->detach($this->application->getEventManager());
     }
     // Set the application.
     $this->application = $application;
     $this->attach($application->getEventManager());
     return $this;
 }
开发者ID:reenl,项目名称:stack-zf2,代码行数:22,代码来源:ZendHttpKernel.php

示例11: testReturnsResponseFromListenerWhenDispatchEventShortCircuits

 /**
  * @group 2981
  */
 public function testReturnsResponseFromListenerWhenDispatchEventShortCircuits()
 {
     $this->application->bootstrap();
     $testResponse = new Response();
     $response = $this->application->getResponse();
     $events = $this->application->getEventManager();
     $events->clearListeners(MvcEvent::EVENT_ROUTE);
     $events->attach(MvcEvent::EVENT_DISPATCH, function ($e) use($testResponse) {
         $testResponse->setContent('triggered');
         return $testResponse;
     }, 100);
     $self = $this;
     $triggered = false;
     $events->attach(MvcEvent::EVENT_FINISH, function ($e) use($self, $testResponse, &$triggered) {
         $self->assertSame($testResponse, $e->getResponse());
         $triggered = true;
     });
     $this->application->run();
     $this->assertTrue($triggered);
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:23,代码来源:ApplicationTest.php

示例12: marshallBadControllerEvent

 /**
  * Marshall a bad controller exception event
  *
  * @param  string $controllerName
  * @param  MvcEvent $event
  * @param  Application $application
  * @param  \Exception $exception
  * @return mixed
  */
 protected function marshallBadControllerEvent($controllerName, MvcEvent $event, Application $application, \Exception $exception)
 {
     $event->setError($application::ERROR_EXCEPTION)->setController($controllerName)->setParam('exception', $exception);
     $events = $application->getEventManager();
     $results = $events->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $event);
     $return = $results->last();
     if (!$return) {
         $return = $event->getResult();
     }
     return $return;
 }
开发者ID:eltondias,项目名称:Relogio,代码行数:20,代码来源:DispatchListener.php

示例13: marshalMiddlewareNotCallable

 /**
  * Marshal a middleware not callable exception event
  *
  * @param  string $type
  * @param  string $middlewareName
  * @param  MvcEvent $event
  * @param  Application $application
  * @param  \Exception $exception
  * @return mixed
  */
 protected function marshalMiddlewareNotCallable($type, $middlewareName, MvcEvent $event, Application $application, \Exception $exception = null)
 {
     $event->setName(MvcEvent::EVENT_DISPATCH_ERROR);
     $event->setError($type);
     $event->setController($middlewareName);
     $event->setControllerClass('Middleware not callable: ' . $middlewareName);
     if ($exception !== null) {
         $event->setParam('exception', $exception);
     }
     $events = $application->getEventManager();
     $results = $events->triggerEvent($event);
     $return = $results->last();
     if (!$return) {
         $return = $event->getResult();
     }
     return $return;
 }
开发者ID:kuisatz,项目名称:ustalarMerkezi,代码行数:27,代码来源:MiddlewareListener.php

示例14: it_dispatches_unauthorized

 /**
  * Valid route but with no login with no login
  */
 public function it_dispatches_unauthorized(MvcEvent $event, RouteMatch $match, EventManagerInterface $eventManager, Application $application, $accessService)
 {
     $application->getEventManager()->willReturn($eventManager);
     $accessService->requiresAuthentication(self::CONTROLLER_ADMIN, 'index')->willReturn(true);
     $accessService->hasUser()->willReturn(false);
     $event->getTarget()->willReturn($application);
     $match->getParam('controller')->willReturn(self::CONTROLLER_ADMIN);
     $match->getParam('action')->willReturn('index');
     $match->getMatchedRouteName()->willReturn('admin');
     $event->getRouteMatch()->willReturn($match);
     $accessService->getRoles()->willReturn([]);
     $eventManager->triggerEvent($event)->shouldBeCalled();
     $event->setError(AccessService::ACCESS_UNAUTHORIZED)->shouldBeCalled();
     $event->setParam('route', 'admin')->shouldBeCalled();
     $event->setParam('controller', self::CONTROLLER_ADMIN)->shouldBeCalled();
     $event->setParam('action', 'index')->shouldBeCalled();
     $event->setParam('roles', 'none')->shouldBeCalled();
     $event->setName(MvcEvent::EVENT_DISPATCH_ERROR)->shouldBeCalled();
     $this->verifyAccess($event);
 }
开发者ID:saeven,项目名称:zf3-circlical-user,代码行数:23,代码来源:AccessListenerSpec.php


注:本文中的Zend\Mvc\Application::getEventManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。