|
|
@@ -8,6 +8,7 @@ use Doctrine\ORM\EntityManagerInterface; |
|
|
|
use Lc\ShopBundle\Context\MerchantUtilsInterface; |
|
|
|
use Lc\ShopBundle\Context\OrderShopInterface; |
|
|
|
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface; |
|
|
|
use Lc\ShopBundle\Context\UserInterface; |
|
|
|
use Symfony\Component\Security\Core\Security; |
|
|
|
|
|
|
|
class OrderUtils |
|
|
@@ -84,6 +85,18 @@ class OrderUtils |
|
|
|
throw new \ErrorException('La commande doit être liée à un merchant.'); |
|
|
|
} |
|
|
|
|
|
|
|
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(); |
|
|
|
|