I need caller model in my behavior to find and save data. How can I do something like this.
class MyBehavior extends Behavior {
public function func() {
$entities = $this->find()->all();
}
I need caller model in my behavior to find and save data. How can I do something like this.
class MyBehavior extends Behavior {
public function func() {
$entities = $this->find()->all();
}
The table instance a behavior is attached to, is being passed to the constructor, and assigned to the $_table
property.
public function func() {
$entities = $this->_table->find()->all();
}
See also API > Cake\ORM\Behaviour::$_table