Yii Front Controller Implementation before Routing -


i want implement language setter controllers , need run method before routing controller -> front controller.

if have implemented method in controller class, usages must run earlier before controller initilisation

class controller extends ccontroller {   public function __construct($id, $module = null)   {       // set application language       if (isset($_get['language']))     {         $lang = $_get['language']; 

you use onbeginrequest event of application. requires add code index.php. here's quick example:

$app = yii::createwebapplication($config); $app->onbeginrequest = function($event) {     // ... whatever want } $app->run(); 

of course instead of closure function can attach other valid callback.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -