I am trying to override preinit method in components/controller.php
public function preinit(){
echo "preinit() called";
}
But i am unable to get access of preinit() method
But when i am overriding the init() method of CModule.php in components/controller.php then it works.
Bizley
(Bizley)
February 12, 2015, 12:25pm
2
There is no method preinit() in CController, only in CModule and CApplication.
You are right but then from where init() method is called CApplication or CModule.
If it is calling from CApplication or CModule then both are calling preinit(), then where this method is called.
CApplication.php
$this->preinit();
$this->initSystemHandlers();
$this->registerCoreComponents();
$this->configure($config);
$this->attachBehaviors($this->behaviors);
$this->preloadComponents();
$this->init();
CModule.php
$this->preinit();
$this->configure($config);
$this->attachBehaviors($this->behaviors);
$this->preloadComponents();
$this->init();
Bizley
(Bizley)
February 12, 2015, 1:41pm
4
In both cases preinit() is called in CModule and CController does not inherit CModule methods. Afaik you cannot override preinit() method in controller.
I want to know to lifecycle of user controller, what i know is ,
[list=1]
[*]Create application object with constructor
[*]init() method
[*]beforeAction()
[*]Controller method
[*]Afteraction
[/list]