get action names from model

Is there a way to get all action names of a controller from a model, I tried this in profile model class:


$profileController=new ProfileController();

    $methods=get_class_methods($profileController);

    foreach($methods as $method){

        if(startswith($method,'action'){....}

    }

but got an error asking to include the profileController.php file, which is not an elegant way to do, does anybody know a better way? thanks for help.

you shouldn’t do that :lol:

this is went against the layer design pattern . the model layer shouldn’t refer to the higher layer(controller layer ) ;

even this can be done as you did:

just import the controller ,use the reflection ;




   Yii::import('application.controllers.ProfileController'); //or moduleId.controllers.XXController ; 

/**

*

      you can use this in your index.php :

   Yii::import('application/moduleId.controllers.*');

*/


   $methods=get_class_methods('ProfileController');

    foreach($methods as $method){

        if(startswith($method,'action'){....}

    }




note as you said this is not a good way. so never access higher layer in layer architecture (you can only access lower layer);