alex-w
(Pr0j3ct A1ex)
1
In my controller i have the actions method
public function actions() {
return array(
'Action1' => 'application.controllers.actions.Action1',
'Action2' => 'application.controllers.actions.Action2'
);
}
That works but I wanted to try and cut out the need for ‘application.controllers’ so created an alias.
//Beginning of config file.
Yii::setPathOfAlias(‘actions’, ‘application.controllers.actions’);
public function actions() {
return array(
'Action1' => 'actions.Action1',
'Action2' => 'actions.Action2'
);
}
But it now errors out, can I not use aliases in this way?
andy_s
(Arekandrei)
2
setPathOfAlias() requires a real path as a second argument, not an alias. If you want to do that in your main config file, then it should look like:
Yii::setPathOfAlias('actions', dirname(__FILE__).'/../controllers/actions'); // it is better to use DIRECTORY_SEPARATOR instead of "/"
alex-w
(Pr0j3ct A1ex)
3
ah, my bad, thought you could alias an alias to shorten it.
jayrulez
(Waprave)
4
Yii::setPathOfAlias(‘actions’, Yii::getPathOfAlias(‘application.controllers.actions’));
andy_s
(Arekandrei)
5
This won’t work in a config file.
jayrulez
(Waprave)
6
Yea i know, since when config is loaded, the alias for application… is not yet set. That should be used elsewhere