Welcome Guest, Not a member yet? Register   Sign In
Using Hook Points
#1

[eluser]jitterbug[/eluser]
Can anyone explain the use of the post-controller-constructor hookpoint? The wiki page says

Called immediately after your controller is instantiated, but prior to any method calls happening.

Would imply that the hook is called after autoload libraries and classes have been loaded. However if you read the print_r($this) in the hook's function youll see that the autoload classes have been declared but hold no data.

It seems like the hooks are hooking to early, because this information is instantiated if you call print_r($this) in the default controller's constructor, and in the hook if the hook is a post-controller hook.

Code:
[load] => CI_Loader Object
        (
            [_ci_ob_level] => 1
            [_ci_view_path] => C:\wamp\www/system/application/views/
            [_ci_is_php5] => 1
            [_ci_is_instance] =>
            [_ci_cached_vars] => Array
                (
                )

            [_ci_classes] => Array
                (
                    [session] => session
                )

            [_ci_loaded_files] => Array
                (
                    [0] => C:\wamp\www/system/libraries/Session.php
                )

            [_ci_models] => Array
                (
                    [0] => userauth
                )

            [_ci_helpers] => Array
                (
                    [string_helper] => 1
                    [url_helper] => 1
                    [form_helper] => 1
                )

            [_ci_plugins] => Array
                (
                )

            [_ci_varmap] => Array
                (
                    [unit_test] => unit
                    [user_agent] => agent
                )

        )

NOTE: If you try to load the session in the post-controller-constructor hook you will get an error b/c the models are not loaded.
Cliffs: Is the post-controller-constructor hook working properly?


Messages In This Thread
Using Hook Points - by El Forum - 01-08-2010, 08:48 PM
Using Hook Points - by El Forum - 01-08-2010, 09:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB