I want to do some pre and post processing of requests like handling authentication, loading contextual data, performance timings and things like that. Coming from Django there's a concept of MIDDLEWARE_CLASSES
that lets me handle the request in various stages: https://docs.djangoproject.com/en/dev/topics/http/middleware/
Currently it seems like each Controller has to do the same setup and load, in the constructor which isn't ideal because if the constructor fails, the class doesn't get initialized which has subtle but important consequences. I want to move this global handling to a global place.
Any suggestions?
There is not. This might be helpful. Codeigniter forum
You need to use hooks for this, Edit your application/config/hooks.php
$hook['post_controller_constructor'][] = array(
'class' => 'Autologin',
'function' => 'cookie_check',
'filename' => 'autologin.php',
'filepath' => 'hooks'
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With