App\Core\Controller::processResponse PHP Method

processResponse() protected method

Create from the given result a Response instance and send it.
protected processResponse ( mixed $response ) : Response
$response mixed
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;
    }