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


PHP Application::run方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: testDispatchingInjectsLocatorInLocatorAwareControllers

 public function testDispatchingInjectsLocatorInLocatorAwareControllers()
 {
     $app = new Application();
     $request = new Request();
     $uri = UriFactory::factory('http://example.local/locator-aware');
     $request->setUri($uri);
     $app->setRequest($request);
     $route = Router\Http\Literal::factory(array('route' => '/locator-aware', 'defaults' => array('controller' => 'locator-aware')));
     $router = $app->getRouter();
     $router->addRoute('locator-aware', $route);
     $locator = new TestAsset\Locator();
     $locator->add('locator-aware', function () {
         return new TestAsset\LocatorAwareController();
     });
     $app->setLocator($locator);
     $storage = new ArrayObject();
     $events = StaticEventManager::getInstance();
     $events->attach('ZendTest\\Mvc\\TestAsset\\LocatorAwareController', 'dispatch', function ($e) use($storage) {
         $controller = $e->getTarget();
         $storage['locator'] = $controller->getLocator();
         return $e->getResponse();
     }, 100);
     $app->run();
     $this->assertTrue(isset($storage['locator']));
     $this->assertSame($locator, $storage['locator']);
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:26,代码来源:ApplicationTest.php

示例5: testFinishShouldRunEvenIfDispatchEventReturnsResponse

 /**
  * @group ZF2-171
  */
 public function testFinishShouldRunEvenIfDispatchEventReturnsResponse()
 {
     $app = new Application();
     $response = $app->getResponse();
     $events = $app->events();
     $events->clearListeners('route');
     $events->attach('dispatch', function ($e) use($response) {
         return $response;
     }, 100);
     $token = new stdClass();
     $events->attach('finish', function ($e) use($token) {
         $token->foo = 'bar';
     });
     $app->run();
     $this->assertTrue(isset($token->foo));
     $this->assertEquals('bar', $token->foo);
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:20,代码来源:ApplicationTest.php

示例6: run

 /**
  * Run the application.
  *
  * @return null
  */
 public function run()
 {
     $this->application->run();
 }
开发者ID:reenl,项目名称:stack-zf2,代码行数:9,代码来源:ZendHttpKernel.php


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