The problem with the post_controller_constructor is it runs after the constructor (funnily enough) and if you use Controller constructors for lots of things this can be a problem.
If it's not a problem for you (your helper wont affect anything run or loaded in your constructors) fair enough, if it IS a problem you have two solutions.
- Instead of the hook put your code in MY_Controller
Create MY_Controller and add in a custom hook point.
class MY_Controller extends Controller
{
function MY_Controller()
{
parent::Controller();
$GLOBALS['EXT']->_call_hook('pre_controller_constructor');
}
}
Note that if you're using CodeIgniter 3.0 or later, the function _call_hook
was renamed to call_hook
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…