I have a controller (A) to manage an object, in the controller I have a method that checks if $this->Auth->user(id) is allowed to access the object.
It is done by accessing an associated model ($this->ModelA->ModelB->...).
Now, in another controller (C) I need to check the same issue (for some internal logic). however, this controller’s model is not associated to ModelB.
So, my problem is : how to check it?
pure SQL is possible but i prefer to avoid it.
the only way I see, is calling the method from another controller..
Put the logic into a method in the
AppControllerso it’s accessible to all controllers.In that method, load the model if necessary: