Hooks - Extending the Framework Core 🔗
application/config/config.php file;
$config['enable_hooks'] = TRUE;
appication/config/hooks.php file;
$hook['pre_controller'] = array(
'class' => 'MyClass',
'function' => 'Myfunction',
'filename' => 'Myclass.php',
'filepath' => 'hooks',
'params' => array('beer', 'wine')
);
$hook['pre_controller'][] = array(
'class' => 'MyClass',
'function' => 'Myfunction',
'filename' => 'Myclass.php',
'filepath' => 'hooks',
'params' => array('beer', 'wine')
);
$hook['pre_controller'][] = array(
'class' => 'MyOtherClass',
'function' => 'MyOtherfunction',
'filename' => 'Myotherclass.php',
'filepath' => 'hooks',
'params' => array('red', 'yellow')
);
Notice the brackets after each array index:
$hook['pre_controller'][]
post_controller_constructed
Called immediately after your controller is instantiated, but prior to any method calls happening.