Get Called Action In Init()

Hi,

one problem solved and yet another shows up.

I added a init() action to the components/Controller.php. In this action I want to get the called ModuleId, ControllerID and ActionID.




class Controller extends CController

{	

    public function init(){

       // only for test

       var_dump(Yii::app()->controller->module->id);

       var_dump(Yii::app()->controller->id);

       var_dump(Yii::app()->controller->action->id);

       die('end of init()');

    }

}



But I never get an ActionID. I Get an ActionID if i copy the code into the called Action, but I want to have this code on a single part of my project.

My question:

Is there a way to get the full Route information in a "global" init() Action?

Thanks for your help.


class Controller extends CController

{       

  protected function beforeAction($action)

  {

    var_dump($action->id, $this->id, $this->module->id);

    

    return parent::beforeAction($action);

  }

}

Hi Tsunami,

thank you very much!

That is exactly what I looked for!

=)