On Sun, Jun 7, 2009 at 5:51 AM, Jasper<[email protected]> wrote: > > I use the code from the docs for moveup and movedown, but I looked up > the code in the class file and I needed to modify the function call to > include $model, and some other little adjustments: > ========================= > function moveDown($id = null, $delta = null) { > if ($id==null) { > $this->Session->setFlash('Please enter an id'); > $this->redirect(array('action' => 'index'), null, > true); > } > $this->Link->id = $id; > if ($delta > 0) { > $this->Link->moveDown($this->Link, $id, $delta); > } else { > $this->Session->setFlash('Please provide the number of > positions > the field should be moved down.'); > } > $this->redirect(array('action' => 'index'), null, > true); > }
No, you don't pass the object to the method. Yes, the API is confusing. What actually happens is that, when a Model implements a Behavior, the latter's methods can be "lent to" the Model, so to speak. If you look at the API for Model::call__() you'll see the first line is: $result = $this->Behaviors->dispatchMethod($this, $method, $params); BehaviorCollection::dispatchMethod(), in turn, passes the Model object to the Behavior's method. The end result is that a Model that "acts as" some Behavior can call that Behavior's methods. By using dispatchMethod() Cake gives the Behavior a handle back to the Model. You don't pass it yourself. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" 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 -~----------~----~----~----~------~----~------~--~---
