One of the first steps may be to iterate over the view files, but then you need to consider that in some cases the views are not the landing pages of the pages, but the sections of the pages included in other pages using CController::renderPartial() . Having studied the CController Class Reference, I came to the CController::actions() method.
So, I did not find any Yii method for iterating over all CController actions, but I used php to iterating over all SiteController methods in one of my projects and filtering them using the prefix action ', which is my action prefix, here is a sample
class SiteController extends Controller{ public function actionTest(){ echo '<h1>Test Page!</h1></p>'; $methods = get_class_methods(get_class($this)); // The action prefix is strlen('action') = 6 $actionPrefix = 'action'; $reversedActionPrefix = strrev($actionPrefix); $actionPrefixLength = strlen($actionPrefix); foreach ($methods as $index=>$methodName){ //Always unset actions(), since it is not a controller action itself and it has the prefix 'action' if ($methodName==='actions') { unset($methods[$index]); continue; } $reversedMethod = strrev($methodName); /* if the last 6 characters of the reversed substring === 'noitca', * it means that $method Name corresponds to a Controller Action, * otherwise it is an inherited method and must be unset. */ if (substr($reversedMethod, -$actionPrefixLength)!==$reversedActionPrefix){ unset($methods[$index]); } else $methods[$index] = strrev(str_replace($reversedActionPrefix, '', $reversedMethod,$replace=1)); } echo 'Actions '.CHtml::listBox('methods', NULL, $methods); } ... }
And I got the result.

I am sure that it can be further clarified, but this method should work for any of the controllers that you have ...
So what you need to do:
For each controller: Filter out all class inactivity methods using the method described above. You can create an associative array, for example
array( 'controllerName1'=>array( 'action1_1', 'action1_2'), 'controllerName2'=>array( 'action2_1', 'action2_2'), );
I would add the static getAllActions () method to my SiteController for this.
get_class_methods , get_class , strrev and strlen are all PHP functions.
Snivs
source share