예제 #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
파일: ArrayToJson.php 프로젝트: fixin/fixin
 /**
  * {@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
파일: JsonToArray.php 프로젝트: fixin/fixin
 /**
  * {@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
파일: ViewRender.php 프로젝트: fixin/fixin
 /**
  * {@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
파일: WrapInView.php 프로젝트: fixin/fixin
 /**
  * {@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;
 }