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


PHP Application::bootstrap方法代碼示例

本文整理匯總了PHP中Zend\Mvc\Application::bootstrap方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::bootstrap方法的具體用法?PHP Application::bootstrap怎麽用?PHP Application::bootstrap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Mvc\Application的用法示例。


在下文中一共展示了Application::bootstrap方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getApplication

 protected function getApplication()
 {
     if (null === $this->application) {
         $this->application = $this->getServiceManager()->get('Application');
         $this->application->bootstrap();
     }
     return $this->application;
 }
開發者ID:outeredge,項目名稱:edge-zf2,代碼行數:8,代碼來源:AbstractTestCase.php

示例2: setupPathController

 public function setupPathController()
 {
     $request = $this->serviceManager->get('Request');
     $uri = UriFactory::factory('http://example.local/path');
     $request->setUri($uri);
     $router = $this->serviceManager->get('HttpRouter');
     $route = Router\Http\Literal::factory(array('route' => '/path', 'defaults' => array('controller' => 'path')));
     $router->addRoute('path', $route);
     $this->application->bootstrap();
 }
開發者ID:pnaq57,項目名稱:zf2demo,代碼行數:10,代碼來源:DispatchListenerTest.php

示例3: testCanRecoverFromApplicationError

 public function testCanRecoverFromApplicationError()
 {
     $this->application->bootstrap();
     $response = $this->getMock('Zend\\Stdlib\\ResponseInterface');
     $errorMock = $this->getMock('stdClass', array('__invoke'));
     $finishMock = $this->getMock('stdClass', array('__invoke'));
     $routeMock = $this->getMock('stdClass', array('__invoke'));
     $dispatchMock = $this->getMock('stdClass', array('__invoke'));
     $errorMock->expects($this->once())->method('__invoke')->will($this->returnCallback(function (MvcEvent $event) {
         $event->stopPropagation(true);
         $event->setRouteMatch(new Router\RouteMatch(array()));
         $event->setError('');
     }));
     $routeMock->expects($this->once())->method('__invoke')->will($this->returnCallback(function (MvcEvent $event) {
         $event->stopPropagation(true);
         $event->setError(Application::ERROR_ROUTER_NO_MATCH);
         return $event->getApplication()->getEventManager()->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $event)->last();
     }));
     $dispatchMock->expects($this->once())->method('__invoke')->will($this->returnValue($response));
     $finishMock->expects($this->once())->method('__invoke')->will($this->returnCallback(function (MvcEvent $event) {
         $event->stopPropagation(true);
     }));
     $this->application->getEventManager()->attach(MvcEvent::EVENT_DISPATCH_ERROR, $errorMock, 100);
     $this->application->getEventManager()->attach(MvcEvent::EVENT_ROUTE, $routeMock, 100);
     $this->application->getEventManager()->attach(MvcEvent::EVENT_DISPATCH, $dispatchMock, 100);
     $this->application->getEventManager()->attach(MvcEvent::EVENT_FINISH, $finishMock, 100);
     $this->application->run();
     $this->assertSame($response, $this->application->getMvcEvent()->getResponse());
 }
開發者ID:pnaq57,項目名稱:zf2demo,代碼行數:29,代碼來源:ApplicationTest.php

示例4: setUp

 public function setUp()
 {
     $config = ['modules' => ['Zff\\Html2Pdf'], 'module_listener_options' => []];
     $serviceManager = new ServiceManager((new ServiceManagerConfig())->toArray());
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     $application = new Application($config, $serviceManager);
     $application->bootstrap();
     $this->serviceManager = $serviceManager;
 }
開發者ID:wizzvet,項目名稱:ZffHtml2pdf,代碼行數:10,代碼來源:ViewHtml2PdfStrategyFactoryTest.php

示例5: testCompleteRequestShouldReturnApplicationInstance

 public function testCompleteRequestShouldReturnApplicationInstance()
 {
     $r = new ReflectionObject($this->application);
     $method = $r->getMethod('completeRequest');
     $method->setAccessible(true);
     $this->application->bootstrap();
     $event = $this->application->getMvcEvent();
     $result = $method->invoke($this->application, $event);
     $this->assertSame($this->application, $result);
 }
開發者ID:razvansividra,項目名稱:pnlzf2-1,代碼行數:10,代碼來源:ApplicationTest.php

示例6: testCustomListener

 public function testCustomListener()
 {
     $this->application->bootstrap(array('BootstrapListener'));
     // must contains custom bootstrap listeners
     $bootstrapListener = $this->serviceManager->get('BootstrapListener');
     $listeners = $this->application->getEventManager()->getListeners(MvcEvent::EVENT_BOOTSTRAP);
     $bootstrapListeners = $bootstrapListener->getListeners();
     $this->assertTrue($listeners->contains($bootstrapListeners[0]));
     // must contains default listeners
     $listeners = $this->application->getEventManager()->getListeners(MvcEvent::EVENT_DISPATCH);
     $this->assertEquals(1, count($listeners));
     $listeners = $this->application->getEventManager()->getListeners(MvcEvent::EVENT_ROUTE);
     $this->assertEquals(1, count($listeners));
     $listeners = $this->application->getEventManager()->getListeners(MvcEvent::EVENT_FINISH);
     $this->assertEquals(1, count($listeners));
 }
開發者ID:rajanlamic,項目名稱:IntTest,代碼行數:16,代碼來源:ApplicationTest.php


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