Welcome Guest, Not a member yet? Register   Sign In
Hooks and base classes
#1

[eluser]tuope[/eluser]
Hello!

If I use 'pre_controller' hooks, I can use CodeIgniter resources (available from `get_instance()') in my hooks, can't I?

Page "http://ellislab.com/codeigniter/user-guide/general/hooks.html" states that in pre_controller phase "All base classes, routing, and security checks have been done". This means that all core classes ("http://ellislab.com/codeigniter/user-guide/general/core_classes.html") are available, right?

Tuomas

P.S. I must say that the CodeIgniter User Guide is a fantastic piece of documentation! :-)
#2

[eluser]WanWizard[/eluser]
The pre-controller hooks is called, as the name implies, before the controller is instantiated. So no access to the CI superobject.
The CI object is available in the post_controller_constructor hook.

You can access the classes already loaded via
Code:
// in CI 1.7.2. use
$RTR = $RTR =& load_class('Router');

// in CI 2.0 use
$RTR =& load_class('Router', 'core');

// after this you can access the class
echo $RTR->fetch_class();
#3

[eluser]tuope[/eluser]
Thank you very much. You probably saved me several hours of frustration caused by my misunderstanding. :-)




Theme © iAndrew 2016 - Forum software by © MyBB