Esempio n. 1
0
 /**
  * {@inheritDoc}
  * @see \Fixin\Delivery\Cargo\CargoHandlerInterface::handle($cargo)
  */
 public function handle(CargoInterface $cargo) : CargoInterface
 {
     if ($cargo instanceof HttpCargoInterface) {
         $method = $cargo->getRequestMethod();
         if (isset(static::METHOD_MAP[$method])) {
             return $this->{static::METHOD_MAP[$method]}($cargo->setStatusCode(Http::STATUS_OK_200));
         }
         return $this->replyMethodNotAllowed($cargo);
     }
     return $cargo;
 }
Esempio n. 2
0
 /**
  * Error route
  *
  * @param CargoInterface $cargo
  */
 protected function errorRoute(CargoInterface $cargo)
 {
     // HTTP cargo
     if ($cargo instanceof HttpCargoInterface) {
         $cargo->setStatusCode(Http::STATUS_INTERNAL_SERVER_ERROR_500);
     }
     try {
         $cargo = $this->container->get($this->config[static::OPTION_ERROR_ROUTE])->handle($cargo);
         $cargo->unpack();
     } catch (\Throwable $t) {
         // Double error
         $this->internalServerError($t->getMessage());
     }
 }