We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

GetPreviousControllerName getting the base controller instead of child controller

Hello I am trying to use the GetPreviousControllerName on the Phalcon dispatcher in order to retrieve the last controller name. This however returns my baseController and not the child that extends the base. Here is a small example:

From

class TestController extends BaseController
{
    //Calls an action on the base class
    //On error 
    $this->dispatcher->setParam("message", "Failure!!");
    $this->dispatcher->setParam("Id", 1234);
                    $this->dispatcher->forward(array("controller" => "general", "action" => "errorConfirmation"));
}

Going To

class GeneralController extends BaseController
{
        public function errorConfirmationAction()
        {
                    // show error then return to
                    $this->view->setVar("link", $this->dispatcher->getPreviousControllerName() . "/view/" . $Id);
        }
}

This returns Base/view/1234

I need it to return Test/View/1234 is this possible?

edited Dec '15

I am using Phalcon 2

Also which version of Phalcon are you using?

I am passing the controller through the dispatcher as I havent found an easy work around