protected function invokeControllerAction(AbstractController $controller, $action)
    {
        $this->invokePluginsHook(
            'beforeActionInvoked',
            array($this, $this->getRequest(), $controller, $action)
        );
        $response = $controller->$action($this->routeParams);
        if (null === $response) {
            // if the action returns null, we simply render the default view
            $response = array();
        } elseif (!is_string($response)) {
            // if they don't return a string, try to use whatever is returned
            // as variables to the view renderer
            $response = (array)$response;
        }

        // merge the response variables with the existing view context
        if (is_array($response)) {
            $response = array_merge($controller->getViewContext(), $response);
        }

        // whatever we have as a response needs to be encapsulated in an
        // AbstractResponse object
        if (!($response instanceof AbstractResponse)) {
            $response = new Response($response);
        }
        $this->invokePluginsHook(
            'afterActionInvoked',
            array($this, $this->getRequest(), $controller, $action, $response)
        );
        return $response;
    }