Controlling calling controller's public methods, is it possible?
<p>The task is to protect calling <strong>public</strong> controller's methods; we need to check if user is administrator or not before calling. </p>

<pre><code>class AdminController {

    final public function __call($name, $arguments) {
        if (!Auth::isAuth()) {
            $User = UserFactory::loadById(Auth::getUserId());
            if (!$User-&gt;isAdmin()) {
                throw new ForbiddenException();
            }
        }
        return call_user_func_array(array($this, $name), $arguments);
    }

}

class AdminCategoryController extends AdminController {

    public function view() { //__call() won't be called bacause it is public method

    }

}
</code></pre>

<p>We can use magic <code>__call()</code> method, but we need all methods to be <code>private</code>.</p>

<p>Another way I see is to define <code>final public __construct()</code> at <code>AdminController</code> and put checking $User->isAdmin() there...</p>

<p>Any other ideas?</p>

<p>Thank you.</p>
