I want to check that user has permissions to invoke some method.
This example works fine
class A
{
public function __call($method, $args)
{
echo 'do something before invoke method</br>';
if(method_exists($this, $method))
{
call_user_func_array(array($this, $method), $args);
}
}
private function testA()
{
echo 'do something what testA has to do';
}
}
but I want to do the validation in every class for every method I thought that this solution will be good for me
class A
{
public function __call($method, $args)
{
echo 'do something before invoke method</br>';
if(method_exists($this, $method))
{
call_user_func_array(array($this, $method), $args);
}
}
}
class B extends A
{
private function testB()
{
echo 'do something what testB has to do</br>';
}
}
I was wrong. I get infinite loop. I need one basic class that will validate user's permission before invoking some method.