我对Code Igniter挂钩有问题。 我正在触发以下两个钩子。第一个是单例。第二个是普通班。
$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()时,出现错误。
消息:找不到类'LoggedInUser'
答案 0 :(得分:0)
对不起,我弄错了。第二个挂钩取代了第一个。现在,下面的代码在数组定义之后的第二个[]处是正确的:
$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' => ""
);