So, I have a PHP class called a router that takes a URL and blows it up to find the requested component, action, and any given values. Then it loads the responsible class, starts the action, etc. Etc. Now I integrate user access to the user through the user class.
For each component (which is a class), I have a class variable of a static class called "perms" that contains each action as an index and a number as the minimum resolution needed to trigger the action. Each component also has a static function to get the permission value for the name of the passed action.
The problem I ran into is getting the static function to work correctly with the name of the class stored in the variable. In the router, I use a variable to store the name of the component.
$this->controller
Then I add it "Controller" to get the class name
$class = $this->controller.'Controller';
However, I get an error when I try to use it to access a static function
$minActionPerm = $class::getPerms( $this->action );
I don't get errors when I literally print the class name, but this is not a real solution.
$minActionPerm = cmsController::getPerms( $this->action );
This variable also works when I create a class object to trigger an action.
$object = new $class();
I am sure this is probably the simple answer - for example, using a variable, but I don't know how it is now.
source
share