3.8.3 Creating behavior methods
Er is geen nog vertaling vertaling voor deze rubriek. Help ons en vertaal dit.. Meer informatie over vertalingen
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.

























