This commit is contained in:
franck
2013-09-04 19:03:37 +02:00
24 changed files with 541 additions and 60 deletions

View File

@@ -2,21 +2,73 @@
namespace Thelia\Model;
use Propel\Runtime\Connection\ConnectionInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Thelia\Core\Event\AddressEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Base\Address as BaseAddress;
class Address extends BaseAddress {
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
protected $dispatcher;
public function setDispatcher(EventDispatcherInterface $dispatcher)
/**
* Code to be run before inserting to database
* @param ConnectionInterface $con
* @return boolean
*/
public function preInsert(ConnectionInterface $con = null)
{
$this->dispatcher = $dispatcher;
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEADDRESS, new AddressEvent($this));
return true;
}
public function getDispatcher()
/**
* Code to be run after inserting to database
* @param ConnectionInterface $con
*/
public function postInsert(ConnectionInterface $con = null)
{
return $this->dispatcher;
$this->dispatchEvent(TheliaEvents::AFTER_CREATEADDRESS, new AddressEvent($this));
}
/**
* Code to be run before updating the object in database
* @param ConnectionInterface $con
* @return boolean
*/
public function preUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEADDRESS, new AddressEvent($this));
return true;
}
/**
* Code to be run after updating the object in database
* @param ConnectionInterface $con
*/
public function postUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_UPDATEADDRESS, new AddressEvent($this));
}
/**
* Code to be run before deleting the object in database
* @param ConnectionInterface $con
* @return boolean
*/
public function preDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_DELETEADDRESS, new AddressEvent($this));
return true;
}
/**
* Code to be run after deleting the object in database
* @param ConnectionInterface $con
*/
public function postDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_DELETEADDRESS, new AddressEvent($this));
}
}

View File

@@ -2,7 +2,7 @@
namespace Thelia\Model;
use Symfony\Component\Config\Definition\Exception\Exception;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\AddressQuery;
use Thelia\Model\Base\Customer as BaseCustomer;
@@ -115,7 +115,7 @@ class Customer extends BaseCustomer implements UserInterface
$con->commit();
} catch(Exception $e) {
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
@@ -225,7 +225,7 @@ class Customer extends BaseCustomer implements UserInterface
*/
public function preUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_CHANGECUSTOMER, new CustomerEvent($this));
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATECUSTOMER, new CustomerEvent($this));
return true;
}
@@ -234,7 +234,7 @@ class Customer extends BaseCustomer implements UserInterface
*/
public function postUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_CHANGECUSTOMER, new CustomerEvent($this));
$this->dispatchEvent(TheliaEvents::AFTER_UPDATECUSTOMER, new CustomerEvent($this));
}
/**