Is there a function that returns all the controllers present in protected/controllers folders.
I need all the controller ids.
For Ex:
for SiteController it should return site
for UserController it should return user
Is there a function that returns all the controllers present in protected/controllers folders.
I need all the controller ids.
For Ex:
for SiteController it should return site
for UserController it should return user
Hi,
nope, there is not.
Properly designed site should never need it.
Anyway, you can easily get list of all controllers like this:
$controllers = array();
$files = CFileHelper::findFiles(realpath(Yii::app()->basePath . DIRECTORY_SEPARATOR . 'controllers'));
foreach($files as $file){
$filename = basename($file, '.php');
if( ($pos = strpos($filename, 'Controller')) > 0){
$controllers[] = substr($filename, 0, $pos);
}
}
print_r($controllers);
Lubos