Exemplo n.º 1
0
 protected function processResponse($response)
 {
     if ($response instanceof Renderable) {
         // If the response is returned from the controller action is a View instance
         // and it is not marked as Layout, we will assume we want to render it on the
         // default templated environment, setup via the current controller properties.
         if (is_string($this->layout) && !$response instanceof Layout) {
             $response = Template::make($this->layout, $this->template)->with('content', $response);
         }
         // Create a proper Response instance.
         $response = new Response($response->render(), 200, array('Content-Type' => 'text/html'));
     }
     if (!$response instanceof SymfonyResponse) {
         $response = new Response($response);
     }
     return $response;
 }
Exemplo n.º 2
0
 /**
  * Create from the given result a Response instance and send it.
  *
  * @param mixed  $response
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function processResponse($response)
 {
     if ($response instanceof Renderable) {
         // If the response which is returned from the called Action is a Renderable instance,
         // we will assume we want to render it using the Controller's templated environment.
         if (is_string($this->layout) && !empty($this->layout) && !$response instanceof Layout) {
             $response = Template::make($this->layout, array(), $this->template)->with('content', $response);
         }
         // Create a proper Response instance.
         $response = new Response($response->render(), 200, array('Content-Type' => 'text/html'));
     }
     // If the response is not a instance of Symfony Response, create a proper one.
     if (!$response instanceof SymfonyResponse) {
         $response = new Response($response);
     }
     return $response;
 }
Exemplo n.º 3
0
 /**
  * Prepare the given value as a Response object.
  *
  * @param  mixed  $value
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function prepareResponse($value)
 {
     if (!$value instanceof SymfonyResponse) {
         $value = new Response($value);
     }
     return $value->prepare($this['request']);
 }
Exemplo n.º 4
0
 /**
  * Create a response instance from the given value.
  *
  * @param  \Symfony\Component\HttpFoundation\Request  $request
  * @param  mixed  $response
  * @return \Nova\Http\Response
  */
 protected function prepareResponse($request, $response)
 {
     if (!$response instanceof SymfonyResponse) {
         $response = new Response($response);
     }
     return $response->prepare($request);
 }