refactor customer and order ref

This commit is contained in:
Manuel Raynaud
2014-04-21 23:29:36 +02:00
parent 55a4edf906
commit 66c5a3729c
8 changed files with 83 additions and 80 deletions

View File

@@ -23,8 +23,6 @@ class Order extends BaseOrder
*/
public function preInsert(ConnectionInterface $con = null)
{
$this->setRef($this->generateRef());
$this->dispatchEvent(TheliaEvents::ORDER_BEFORE_CREATE, new OrderEvent($this));
return true;
@@ -35,6 +33,8 @@ class Order extends BaseOrder
*/
public function postInsert(ConnectionInterface $con = null)
{
$this->setRef($this->generateRef())
->save($con);
$this->dispatchEvent(TheliaEvents::ORDER_AFTER_CREATE, new OrderEvent($this));
}
@@ -49,9 +49,7 @@ class Order extends BaseOrder
public function generateRef()
{
/* order addresses are unique */
return uniqid('ORD', true);
return sprintf('ORD%s', str_pad($this->getId(), 12, 0, STR_PAD_LEFT));
}
/**