本文整理汇总了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;
}
示例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();
}
示例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());
}
示例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;
}
示例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);
}
示例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));
}