I have a Behavior attached to a Model that should behave differently depending on some property of the model. Example:
class Airplane extends AppModel {
var $actsAs = array('Flying');
}
class FlyingBehavior extends ModelBehavior {
function flightTime(&$Model, $distance) {
return $distance / $this->speed;
}
}
Initially I thought I setting it like
class Airplane extends AppModel {
var $actsAs = array('Flying' =>
array('speed' => SOMENUM)
);
}
class FlyingBehavior extends ModelBehavior {
function setup(&$Model, $settings) {
$this->speed = $settings['speed'];
}
function flightTime(&$Model, $distance) {
return $distance / $this->speed;
}
}
But I don't know how to make this work, because I'd need to fetch the speed
column from each Airplane
record. How should I do this?