Closed mikebranderhorst closed 12 years ago
This was changed, if it were a bug the whole Request would break down.
So the only method getting the controller name (not class name) is $this->request->router->segments[0] while it was $this->reguest->controller. What about if segment[0] is a module? It was nice to have (in 1.0):
$this->request->module $this->request->controller $this->request->action
The reason I reported it as a bug is that Stationwagon example will break when updating to 1.1. https://github.com/abdelm/stationwagon/blob/develop/fuel/app/classes/controller/common.php There are a lot of examples online using Auth::has_access(array($this->request->controller,...)) What would be the new method getting the controller name? http://fuelphp.com/forums/topics/view/5517
First off: we don't code this for any particular application, thus how Stationwagon handles this is up to them.
The reason this was done is that Controllers used to be located by the Request class, which was wrong from a logical point of view. The controller is now located by the Router and then passed on as a full classname. This won't change.
How to handle this? That's up to you, one way might be something like this:
// Denamespaces the controller (in case of module) and strips "Controller_" from the classname using substr()
$controller = substr(Inflector::denamespace($this->request->controller), 11);
Besides that, the comment of @mikebranderhorst is wrong.
It now DOES return the class name, instead of the URI segment that referred to the controller class.
This issue has been discussed in the forum some time ago. If Auth::has_access() is used in an app with a controller name as parameter, it is up to the app to make sure the correct parameter is passed. In case of Stationwagon, that is/was a design decision by the author to implement it like that, the framework doesn't dicate that.
The value of $this->request->controller is changed in 1.1/develop from "profile" to "\Controller_Profile" when using a Profile controller. Is this a bug or a new way to return the controller name?