Issue
I have set up basic skeleton Yii app, with Rights and User extensions. Rights works fine, except for User. I'm using NetBeans 8.0.1.
I have put this code into SiteController and UserController as in the instructions:
public function filters() {
return array(
'rights',
);
}
I have noticed a strange thing. Here:
class SiteController extends Controller {
when I was going over the word Controller
with the mouse cursor holding CTRL, in a pop-up window NetBeans showed where it was pointing to. It was pointing to the Controller in the application directory. This is what I expected, and I thought it works because Controller extends RController and so on.
For UserController, it was not working.
class UserController extends Controller {
Now when I go over the word Controller
with the mouse cursor holding CTRL, in a pop-up window NetBeans showes that it is pointing to the Controller not in the application directory but to the Controller in the framework directory. I thought this is why it's not working. But since I clicked on it, and jumped to this file, NetBeans shows the same framework Controller for SiteController also, but it still works! So I don't know now if it's only a NetBeans bug or what. But no matter what, what I only care for for is that Rights works for UserController also.
How can I define my UserController to point to the Controller in the application, and not in the framework. But maybe it points to the right place, it's just NetBeans what shows it incorrectly. But if not this is the problem, than what?
UPDATE:
I have noticed a thing: somewhere Rights works for User, e.g. when I see this in the address bar:
project/user/user/view/id/1
it seems to me as it would be user module, then user class, action etc. But when it's not working, I see only:
project/user
is it not using class user? Or what happens here? What controller is in use? None?!
Solution
I've figured it out (I guess). In:
app/modules/user/controllers
there are more controllers, and I have put
public function filters() {
return array(
'rights',
);
}
only in UserController, that's why it was only working when I called:
project/user/user/...
Now there is also DefaultController. That's used, when no other controller is defined in the route. I have put rights filters in DefaultController also, and now it works there also. So what NetBeans shows as path to Controller is probably only a bug, but I'm not sure, I'm not that professional to decide.
Answered By - user2511599