2011年2月1日星期二

[fw-mvc] PHP strict notice fired on a custom controller plugin

I keep getting this warning in my log file:

"PHP Strict Standards: Declaration of My_Plugin_AuthAccess::preDispatch()
should be compatible with that of
Zend_Controller_Plugin_Abstract::preDispatch() in /var/www/
mywebsite.com/application/plugins/AuthAccess.php on line 86"

The line referenced is the last line of the file. I've left out the
commenting at the head of the file, here's the class:

class My_Plugin_AuthAccess extends Zend_Controller_Plugin_Abstract
{
public function preDispatch($request)
{
$notAuthenticated = array(
'login', // controller
'index', // action
);
$notAllowed = array(
'error', // controller
'privileges', // action
);
$acl = Zend_Registry::get('acl');
$auth = Zend_Auth::getInstance();
$redirector =
Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
if ($auth->hasIdentity()) {
$role = 'member';
} else {
$role = 'guest';
}
$resource = $request->controller;
if (!$acl->has($resource)) {
$resource = NULL;
}
if ('blog' === $resource) {
$rule = $request->action;
if (!$acl->isAllowed($role, $resource, $rule)) {
if (!$auth->hasIdentity()) {
list($controller, $action) = $notAuthenticated;
} else {
list($controller, $action) = $notAllowed;
}
$redirector->gotoSimpleAndExit($action, $controller, null, array('goto' =>
"$resource+$rule"));
}
} else {
if (!$acl->isAllowed($role, $resource)) {
if (!$auth->hasIdentity()) {
list($controller, $action) = $notAuthenticated;
} else {
list($controller, $action) = $notAllowed;
}
$redirector->gotoSimpleAndExit($action, $controller, null, array('goto' =>
$resource));
}
}
}

I have looked at the source of the Abstract class and *thought* I had my
extended class definition correct, but I must be missing something. Any
ideas on what I need to change/add/remove from my class definition in order
to be compliant and avoid the error?

--regards,
nathan

没有评论: