Exemple #1
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());
     }
 }
Exemple #2
0
 /**
  * Load lazy property
  *
  * @param string $propertyName
  * @param array $prototypeOptions
  * @throws InvalidArgumentException
  * @return mixed
  */
 protected function loadLazyProperty(string $propertyName, array $prototypeOptions = [])
 {
     if (isset($this->lazyLoadingProperties[$propertyName])) {
         $set = $this->lazyLoadingProperties[$propertyName];
         $interface = $set[1];
         $value = is_subclass_of($interface, PrototypeInterface::class) ? $this->container->clonePrototype($set[0], $prototypeOptions) : $this->container->get($set[0]);
         if ($value instanceof $interface) {
             return $this->{$propertyName} = $value;
         }
         throw new InvalidArgumentException(sprintf(InvalidArgumentException::INVALID_RESOURCE, $propertyName, $interface));
     }
     return $this->{$propertyName} = null;
 }