@@ -4,6 +4,7 @@ namespace Lc\ShopBundle\Model; | |||
use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Gedmo\Mapping\Annotation as Gedmo; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\ShopBundle\Context\DocumentInterface; | |||
use Lc\ShopBundle\Context\FilterMerchantInterface; | |||
@@ -95,6 +96,20 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa | |||
*/ | |||
protected $documents; | |||
/** | |||
* @Gedmo\Blameable(on="create") | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $createdBy; | |||
/** | |||
* @Gedmo\Blameable(on="update") | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $updatedBy; | |||
public function __construct() | |||
{ | |||
$this->orderStatusHistories = new ArrayCollection(); |
@@ -3,6 +3,8 @@ | |||
namespace Lc\ShopBundle\Model; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Gedmo\Mapping\Annotation as Gedmo; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
@@ -26,6 +28,20 @@ abstract class OrderStatusHistory extends AbstractEntity | |||
*/ | |||
protected $origin; | |||
/** | |||
* @Gedmo\Blameable(on="create") | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $createdBy; | |||
/** | |||
* @Gedmo\Blameable(on="update") | |||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $updatedBy; | |||
public function getOrderShop(): ?OrderShop | |||
{ | |||
return $this->orderShop; |
@@ -121,17 +121,6 @@ class OrderUtils | |||
$orderShop = $this->setOrderStatus('cart', $orderShop); | |||
if ($this->security->getUser()) { | |||
$orderShop->setCreatedBy($this->security->getUser()); | |||
$orderShop->setUpdatedBy($this->security->getUser()); | |||
} else { | |||
// createdBy doit pouvoir être NULL pour OrderShop, en attendant qu'on en discute, j'assigne ça au premier de la base | |||
$userRepository = $this->em->getRepository($this->em->getClassMetadata(UserInterface::class)->getName()); | |||
$user = $userRepository->find(1); | |||
$orderShop->setCreatedBy($user); | |||
$orderShop->setUpdatedBy($user); | |||
} | |||
$this->em->persist($orderShop); | |||
$this->em->flush(); | |||