gilles.bourgeat@gmail.com> */ trait ModelEventDispatcherTrait { use TheliaModelEventDispatcherTrait; protected function getTableName() { $tableMapClass = self::TABLE_MAP; return $tableMapClass::TABLE_NAME; } /** * Code to be run before inserting to database * @param ConnectionInterface $con * @return boolean */ public function preInsert(ConnectionInterface $con = null) { parent::preInsert($con); if ($this->getDispatcher() !== null) { /** @var ActiveRecordInterface $this */ $event = new PropelEvent($this); /** @var ModelEventDispatcherTrait $this */ $this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_PRE_INSERT . $this->getTableName(), $event); if ($event->isPropagationStopped()) { return false; } } return true; } /** * Code to be run after inserting to database * @param ConnectionInterface $con */ public function postInsert(ConnectionInterface $con = null) { parent::postInsert($con); if ($this->getDispatcher() !== null) { /** @var ActiveRecordInterface $this */ $event = new PropelEvent($this); /** @var ModelEventDispatcherTrait $this */ $this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_POST_INSERT . $this->getTableName(), $event); } } /** * Code to be run before updating the object in database * @param ConnectionInterface $con * @return boolean */ public function preUpdate(ConnectionInterface $con = null) { parent::preUpdate($con); if ($this->getDispatcher() !== null) { /** @var ActiveRecordInterface $this */ $event = new PropelEvent($this); /** @var ModelEventDispatcherTrait $this */ $this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_PRE_UPDATE . $this->getTableName(), $event); if ($event->isPropagationStopped()) { return false; } } return true; } /** * Code to be run after updating the object in database * @param ConnectionInterface $con */ public function postUpdate(ConnectionInterface $con = null) { parent::postUpdate($con); if ($this->getDispatcher() !== null) { /** @var ActiveRecordInterface $this */ $event = new PropelEvent($this); /** @var ModelEventDispatcherTrait $this */ $this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_POST_UPDATE . $this->getTableName(), $event); } } /** * Code to be run before deleting the object in database * @param ConnectionInterface $con * @return boolean */ public function preDelete(ConnectionInterface $con = null) { parent::preDelete($con); if ($this->getDispatcher() !== null) { /** @var ActiveRecordInterface $this */ $event = new PropelEvent($this); /** @var ModelEventDispatcherTrait $this */ $this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_PRE_DELETE . $this->getTableName(), $event); if ($event->isPropagationStopped()) { return false; } } return true; } /** * Code to be run after deleting the object in database * @param ConnectionInterface $con */ public function postDelete(ConnectionInterface $con = null) { parent::postDelete($con); if ($this->getDispatcher() !== null) { /** @var ActiveRecordInterface $this */ $event = new PropelEvent($this); /** @var ModelEventDispatcherTrait $this */ $this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_POST_DELETE . $this->getTableName(), $event); } } }