コード例 #1
0
ファイル: HttpRouterKernel.php プロジェクト: Festiv/Festiv
 /**
  * {@inheritdoc}
  */
 public function execute(ContainerInterface $app)
 {
     // @todo remove ErrorHandlerProvider
     // @todo add Error handler, and Whoops pretty when debug === true in Error Handler.
     $request = $app->get(ServerRequestFactory::class)->fromGlobals();
     try {
         $response = $this->dispatch($app->get('router'), $request);
         $app->get(ResponseSender::class)->sendToGlobal($response);
     } catch (Exception $exception) {
         if ($exception instanceof HttpException) {
             $httpException = $exception;
         } else {
             // if not HttpException and debug mode, exception will be prettify(by Whoops).
             if ($app['config']->get('debug', true)) {
                 throw $exception;
             }
             $httpException = new HttpException();
         }
         $handler = $app['config']->get('error.handler');
         if ($handler) {
             $response = $this->responsify($app->create($handler)->handle($request, $exception), $httpException);
         } else {
             $response = $httpException->toResponse();
         }
         // body is ''
         if (!$response->getBody()) {
             $body = $response->getReasonPhrase();
             $response = $response->withBody(new Stringstream($body));
         }
         $app->get(ResponseSender::class)->sendToGlobal($response);
     }
 }
コード例 #2
0
 public function boot(ContainerInterface $app)
 {
     if ($app->has(KernelInterface::class)) {
         $kernel = $app->get(KernelInterface::class);
         $kernel['commands'] = (require __DIR__ . '/../app/commands.php');
         $kernel['routes'] = (require __DIR__ . '/../app/routes.php');
     }
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function boot(ContainerInterface $app)
 {
     if ($app->has(KernelInterface::class)) {
         /** @var \Wandu\Foundation\Contracts\KernelInterface $kernel */
         $kernel = $app->get(KernelInterface::class);
         $kernel['commands'] = ['psysh' => PsyshCommand::class, 'install' => InstallCommand::class];
     }
 }
コード例 #4
0
ファイル: HttpRouterKernel.php プロジェクト: wandu/framework
 /**
  * @param \Wandu\DI\ContainerInterface $app
  * @return \Psr\Http\Message\ServerRequestInterface
  */
 protected function createRequest(ContainerInterface $app)
 {
     return $this->request = $app->get(ServerRequestFactory::class)->createFromGlobals();
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function boot(ContainerInterface $app)
 {
     $app->get(DispatcherInterface::class)->setListeners($this->listeners);
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function boot(ContainerInterface $app)
 {
     $app->get(Manager::class)->setAsGlobal();
     $app->get(Manager::class)->bootEloquent();
 }
コード例 #7
0
ファイル: WanduLoaderTest.php プロジェクト: wandu/framework
 public function equalSession(Session $session, SessionInterface $sessionInterface, ServerRequestInterface $request, ContainerInterface $container)
 {
     return $session === $sessionInterface && $session === $request->getAttribute('session') && $container->get('request') === $request && $container->get(ServerRequest::class) === $request && $container->get(ServerRequestInterface::class) === $request;
 }
コード例 #8
0
 public function boot(ContainerInterface $app)
 {
     $app->get('mockery')->boot();
 }
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 public function execute(ContainerInterface $app)
 {
     $request = $app[ServerRequestFactory::class]->fromGlobals();
     $method = strtoupper($request->getMethod());
     if (!isset($this->routes[$method])) {
         throw new MethodNotAllowedException();
     }
     $response = $this->routes[$method]->execute($app[ServerRequestFactory::class]->fromGlobals(), $app[ClassLoaderInterface::class]);
     $app->get(ResponseSender::class)->sendToGlobal($response);
 }