3.8.3 Creating behavior methods
Es gibt zur Zeit keine Übersetzung für diesen Abschnitt. Bitte hilf mit und übersetze ihn. Mehr Informationen zu Übersetzungen
Behavior methods are automatically available on any model acting as the behavior. For example if you had:
class Duck extends AppModel {
var $name = 'Duck';
var $actsAs = array('Flying');
}
class Duck extends AppModel {var $name = 'Duck';var $actsAs = array('Flying');}
You would be able to call FlyingBehavior methods as if they were methods on your Duck model. When creating behavior methods you automatically get passed a reference of the calling model as the first parameter. All other supplied parameters are shifted one place to the right. For example
$this->Category->fly('toronto', 'montreal');
$this->Category->fly('toronto', 'montreal');
function fly(&$Model, $from, $to) {
// Do some flying.
}
function fly(&$Model, $from, $to) {// Do some flying.}
$this->doIt() fashion from inside a behavior method will not get the $model parameter automatically appended.

























