ModelBehavior (class)
Class ModelBehavior
Model behavior base class.
Defines the Behavior interface, and contains common model interaction functionality. Behaviors allow you to simulate mixins, and create reusable blocks of application logic, that can be reused across several models. Behaviors also provide a way to hook into model callbacks and augment their behavior.
Mixin methods
Behaviors can provide mixin like features by declaring public methods. These methods should expect the model instance to be shifted onto the parameter list.
function doSomething(Model $model, $arg1, $arg2) { //do something }
Would be called like $this->Model->doSomething($arg1, $arg2);
.
Mapped methods
Behaviors can also define mapped methods. Mapped methods use pattern matching for method invocation. This allows you to create methods similar to Model::findAllByXXX methods on your behaviors. Mapped method