The automagic param pushing is only done when delegated from a model.
For example you if have a model and behavior:

class Coffee extends AppModel {
  var $actsAs  = array('Stimulant');
}

class StimulantBehavior extends ModelBehavior {
  function wakeUp(&$model) {
    // Do something
  }
}

If you ever try to call Coffee::wakeUp() [in a controller it would be
$this->Coffee->wakeUp(); or from inside Coffee it would be $this-
>wakeUp()], and the wakeUp() function does not exist in Coffee (or in
AppModel), then the behaviors are checked for the method name, and if
it is found, then it is called with the referring model as the first
parameter, i.e. StimulantBehavior::wakeUp(Coffee)]. This only applies
to public methods (in CakePHP: methods not starting with an
underscore).

The details can be found in /cake/libs/model/model.php [inisde
function call__($method, $params) ]

However, if called directly [say from within the behavior itself:
$this->wakeUp()], no extra parameter is pushed.



On 24 Jul, 10:05, Fran Iglesias <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've been playing with behaviors for a project and I want to ask if
> behavior methods "automagically" get the model as the first argument.
>
> This seems clear with callback methods, but I found this happening in
> public methods as well. So, I guess you can invoke a method form a
> behavior without passing a reference to the model, isn't it?
> --
> Fran Iglesias
> [EMAIL PROTECTED]


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to