modification of model Order to not insert two times the order_version (when we insert for the first time an order object)

This commit is contained in:
Guillaume Barral
2014-06-19 12:02:58 +02:00
parent e5691b9793
commit 60124feb17

View File

@@ -17,6 +17,8 @@ class Order extends BaseOrder
protected $choosenDeliveryAddress = null;
protected $choosenInvoiceAddress = null;
protected $disableVersioning = false;
/**
* @param null $choosenDeliveryAddress
*/
@@ -27,6 +29,30 @@ class Order extends BaseOrder
return $this;
}
/**
* @param boolean $disableVersionning
*/
public function setDisableVersioning($disableVersioning)
{
$this->disableVersioning = (bool) $disableVersioning;
return $this;
}
public function isVersioningDisable()
{
return $this->disableVersioning;
}
public function isVersioningNecessary($con = null)
{
if ($this->isVersioningDisable()) {
return false;
} else {
return parent::isVersioningNecessary($con);
}
}
/**
* @return null
*/
@@ -69,6 +95,7 @@ class Order extends BaseOrder
public function postInsert(ConnectionInterface $con = null)
{
$this->setRef($this->generateRef())
->setDisableVersioning(true)
->save($con);
$this->dispatchEvent(TheliaEvents::ORDER_AFTER_CREATE, new OrderEvent($this));
}