我对代码点火器钩子有问题。我正在触发以下两个钩子。第一个是单例。第二个是普通课程。
$hook['post_controller_constructor'] = array(
'class' => 'LoggedInUser',
'function' => 'getInstance',
'filename' => 'LoggedInUser.php',
'filepath' => 'hooks',
'params' => ""
);
$hook['post_controller_constructor'] = array(
'class' => 'SecureController',
'function' => 'verifyCredentials',
'filename' => 'SecureController.php',
'filepath' => 'hooks',
'params' => ""
);
当我尝试访问 SecureController 类中的 LoggedInUser::methodName(( 时,出现错误。
消息:找不到类"登录用户">
对不起,我弄错了。第二个钩子正在取代第一个钩子。以下代码现在是正确的,在数组定义之后有第二个 []:
$hook['post_controller_constructor'][] = array(
'class' => 'LoggedInUser',
'function' => 'getInstance',
'filename' => 'LoggedInUser.php',
'filepath' => 'hooks',
'params' => ""
);
$hook['post_controller_constructor'][] = array(
'class' => 'SecureController',
'function' => 'verifyCredentials',
'filename' => 'SecureController.php',
'filepath' => 'hooks',
'params' => ""
);