3.8.3 Creating behavior methods
このセクションには保留されている変更があります. More information about translations
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.

























