I need the controller name of Yii::app()->user->returnUrl. Is it possible?
I need the controller name of Yii::app()->user->returnUrl. Is it possible?
Try to print the value of returnUrl and see what it returns and decide whether you could get the controller name out of the result somehow
For more info on returnUrl please refer to the documentation: http://www.yiiframework.com/doc/api/1.1/CWebUser#returnUrl-detail
I take it you’re wanting to find the controller that would be instantiated from a URI path? If that’s the case, an appropriate course of action would be to try to leverage how Yii converts a URI path in to a controller component. While this may not be the most effective method, just from a quick look through CWebApplication.php, you can see that the createController() method instantiates a controller object from a URI.
So, for instance, if I set my set my returnUrl to:
/test/helloWorld?name=alex
I can then grab the class name of the instantiated controller of that route with:
$route = Yii::app()->createController(Yii::app()->user->returnUrl);
$className = get_class($route[0]);
$className would resolve to TestController.
Thank you friends
this will give you the controller name Yii::$app->controller->id e.g TestController you will get test as result