Models are instantiated before running beforeFilter(). You can see this by
looking at dispatch() in class Dispatcher, located at cake/dispatcher.php:
1. Creates the controller: $controller =& new $ctrlClass();
2. Initializes components: $controller->_initComponents()
3. Initializes models in the controller: $controller->constructClasses()
4. Invokes the action: $this->_invoke($controller, $params, $missingAction)
Then Dispatcher::_invoke():
1. Starts the controller (see below): $this->start($controller);
2. Executes the action and get its output.
3. Runs afterFilter(): $controller->afterFilter();
Now Dispatcher::start() does:
1. If there are functions defined in the array $beforeFilter, execute each
one of them (if they are callables): $controller->$filter();
2. Runs main beforeFilter: $controller->beforeFilter();
3. Starts up each component: $controller->{$c}->startup($controller);
I guess my point is by looking at the source code you can learn a lot. Just
ask Felix and Andy ;)
-MI
---------------------------------------------------------------------------
Remember, smart coders answer ten questions for every question they ask.
So be smart, be cool, and share your knowledge.
BAKE ON!
blog: http://www.MarianoIglesias.com.ar
-----Mensaje original-----
De: [email protected] [mailto:[EMAIL PROTECTED] En nombre
de AD7six
Enviado el: Jueves, 01 de Marzo de 2007 12:42 p.m.
Para: Cake PHP
Asunto: Re: error: Call to a member function requestAction() on a non-object
So this: var $uses = array('Category'); is the key here. Because I am doing
a beforeFilter(), my model wasn't loaded yet.?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---