I am trying to use Events Manager example as described at http://docs.phalconphp.com/en/latest/reference/models.html#using-a-custom-events-manager.
class Products extends Phalcon\Mvc\Model
{
public function initialize()
{
$eventsManager = new Phalcon\Events\Manager();
$eventsManager->attach('model', function($event, $robot) {
// Do something (or nothing at all).
return true;
});
$this->setEventsManager($eventsManager);
$this->setSource('products');
}
}
$o = Products::findFirst();
$o->we = 5;
$o->save();
This results in the following error:
Script raised E_ERROR with message "Phalcon\Mvc\Model\Manager::notifyEvent(): Call to method fire() on a non-object"
What am I missing in EventsManager setup?
I am on Phalcon 1.3.0.
Thanks, Temuri