views:

45

answers:

1

What is the best way to do and equivalent to CakePHP's beforeFilter() in codeIgniter

+4  A: 

sounds like hooks might be what you're after

CakePHP beforeFilter()

This function is executed before every action in the controller. It's a handy place to check for an active session or inspect user permissions.or inspect user permissions.

CodeIgniter pre controller

Called immediately prior to any of your controllers being called. All base classes, routing, and security checks have been done.

$hook['pre_controller'] = array(
                                'class'    => 'MyClass',
                                'function' => 'Myfunction',
                                'filename' => 'Myclass.php',
                                'filepath' => 'hooks',
                                'params'   => array('beer', 'wine', 'snacks')
                                );

maybe?

Ross
in application/config/config.php ensure you have $config['enable_hooks'] = TRUE;
dryprogrammers