示例#1
0
 /**
  * {@inheritDoc}
  * @see \Fixin\Delivery\Cargo\CargoHandlerInterface::handle($cargo)
  */
 public function handle(CargoInterface $cargo) : CargoInterface
 {
     if ($cargo->getContent() instanceof \Throwable) {
         $cargo->setContent(Ground::debugText(htmlspecialchars($cargo->getContent())))->setContentType(static::CONTENT_TYPE);
     }
     return $cargo;
 }
示例#2
0
 /**
  * {@inheritDoc}
  * @see \Fixin\Delivery\Cargo\CargoHandlerInterface::handle($cargo)
  */
 public function handle(CargoInterface $cargo) : CargoInterface
 {
     if (is_array($cargo->getContent())) {
         $cargo->setContent($this->container->get('Base\\Json\\Json')->encode($cargo->getContent()))->setContentType(static::CONTENT_TYPE);
     }
     return $cargo;
 }
示例#3
0
 /**
  * {@inheritDoc}
  * @see \Fixin\Delivery\Cargo\CargoHandlerInterface::handle($cargo)
  */
 public function handle(CargoInterface $cargo) : CargoInterface
 {
     if (in_array($cargo->getContentType(), static::ALLOWED_TYPES)) {
         $cargo->setContent($this->container->get('Base\\Json\\Json')->decode($cargo->getContent()));
     }
     return $cargo;
 }
示例#4
0
 /**
  * {@inheritDoc}
  * @see \Fixin\Delivery\Cargo\CargoHandlerInterface::handle($cargo)
  */
 public function handle(CargoInterface $cargo) : CargoInterface
 {
     $content = $cargo->getContent();
     if ($content instanceof ViewInterface) {
         $cargo->setContent($content->render())->setContentType($content->getContentType());
     }
     return $cargo;
 }
示例#5
0
 /**
  * {@inheritDoc}
  * @see \Fixin\Delivery\Cargo\CargoHandlerInterface::handle($cargo)
  */
 public function handle(CargoInterface $cargo) : CargoInterface
 {
     if (in_array($cargo->getContentType(), static::ALLOWED_TYPES)) {
         $content = $cargo->getContent();
         $view = $this->container->clonePrototype('View\\View');
         $view->setTemplate($this->template);
         $cargo->setContent($view);
         if ($content instanceof ViewInterface) {
             $view->setChild($this->contentName, $content);
             return $cargo;
         }
         $view->setVariable($this->contentName, $content);
     }
     return $cargo;
 }