System\Route::run PHP Method

run() public method

Calls the route actions and returns a response object
public run ( ) : object
return object
    public function run()
    {
        // Call before actions
        $response = $this->before();
        // If we didn't get a response run the main callback
        if (is_null($response)) {
            $response = call_user_func_array($this->callbacks['main'], $this->args);
        }
        // Call any after actions
        $this->after($response);
        // If we have a response object return it
        if ($response instanceof Response) {
            return $response;
        }
        // If the response was a view get the output and create response
        if ($response instanceof View) {
            $response = $response->render();
        } elseif (is_object($response) and method_exists($response, '__toString')) {
            $response = (string) $response;
        } elseif (ob_get_length()) {
            $response = ob_get_clean();
        }
        return Response::create($response);
    }