From ea94a54280be069d2cac920650f329ecb489826a Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 7 Oct 2013 10:59:58 +0200 Subject: [PATCH] add pre/post CRUD method in Country model --- core/lib/Thelia/Model/Country.php | 39 ++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Model/Country.php b/core/lib/Thelia/Model/Country.php index 56a7667cf..9dc409910 100755 --- a/core/lib/Thelia/Model/Country.php +++ b/core/lib/Thelia/Model/Country.php @@ -2,11 +2,48 @@ namespace Thelia\Model; +use Propel\Runtime\Connection\ConnectionInterface; +use Thelia\Core\Event\Country\CountryEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\Country as BaseCountry; -class Country extends BaseCountry { +class Country extends BaseCountry +{ + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + public function preInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_CREATECOUNTRY, new CountryEvent($this)); + return true; + } + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATECOUNTRY, new CountryEvent($this)); + } + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATECOUNTRY, new CountryEvent($this)); + + return true; + } + + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATECOUNTRY, new CountryEvent($this)); + } + + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETECOUNTRY, new CountryEvent($this)); + + return true; + } + + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETECOUNTRY, new CountryEvent($this)); + } }