當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。