소스 검색

OrderUtils : adaptation createOrderShop en attendant de trouver une solution pour le createdBy et le updatedBy

feature/export_comptable
Guillaume 4 년 전
부모
커밋
2b99576451
1개의 변경된 파일13개의 추가작업 그리고 0개의 파일을 삭제
  1. +13
    -0
      ShopBundle/Services/OrderUtils.php

+ 13
- 0
ShopBundle/Services/OrderUtils.php 파일 보기

@@ -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();


Loading…
취소
저장