|
|
@@ -7,28 +7,27 @@ use Lc\CaracoleBundle\Factory\Product\ProductFamilySectionPropertyFactory; |
|
|
|
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; |
|
|
|
use Lc\CaracoleBundle\Model\Section\SectionInterface; |
|
|
|
use Lc\CaracoleBundle\Repository\Product\ProductFamilySectionPropertyStore; |
|
|
|
use Lc\CaracoleBundle\Solver\Product\ProductFamilySectionPropertySolver; |
|
|
|
|
|
|
|
class ProductFamilySectionPropertyBuilder |
|
|
|
{ |
|
|
|
protected EntityManagerInterface $entityManager; |
|
|
|
protected ProductFamilySectionPropertyFactory $productFamilySectionPropertyFactory; |
|
|
|
protected ProductFamilySectionPropertyStore $productFamilySectionPropertyStore; |
|
|
|
protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver; |
|
|
|
|
|
|
|
public function __construct( |
|
|
|
EntityManagerInterface $entityManager, |
|
|
|
ProductFamilySectionPropertyFactory $productFamilySectionPropertyFactory, |
|
|
|
ProductFamilySectionPropertyStore $productFamilySectionPropertyStore |
|
|
|
ProductFamilySectionPropertySolver $productFamilySectionPropertySolver |
|
|
|
) { |
|
|
|
$this->entityManager = $entityManager; |
|
|
|
$this->productFamilySectionPropertyFactory = $productFamilySectionPropertyFactory; |
|
|
|
$this->productFamilySectionPropertyStore = $productFamilySectionPropertyStore; |
|
|
|
$this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver; |
|
|
|
} |
|
|
|
|
|
|
|
public function enable(ProductFamilyInterface $productFamily, SectionInterface $section, bool $flush = true): void |
|
|
|
{ |
|
|
|
$productFamilySectionProperty = $this->productFamilySectionPropertyStore |
|
|
|
->setSection($section) |
|
|
|
->getOneByProductFamily($productFamily); |
|
|
|
$productFamilySectionProperty = $this->productFamilySectionPropertySolver->getProductFamilySectionProperty($productFamily, $section); |
|
|
|
|
|
|
|
if ($productFamilySectionProperty) { |
|
|
|
if (!$productFamilySectionProperty->getStatus()) { |
|
|
@@ -38,7 +37,9 @@ class ProductFamilySectionPropertyBuilder |
|
|
|
} else { |
|
|
|
$productFamilySectionProperty = $this->productFamilySectionPropertyFactory->create($section, $productFamily); |
|
|
|
$productFamilySectionProperty->setStatus(1); |
|
|
|
$productFamily->addProductFamilySectionProperty($productFamilySectionProperty); |
|
|
|
$this->entityManager->create($productFamilySectionProperty); |
|
|
|
$this->entityManager->update($productFamily); |
|
|
|
} |
|
|
|
|
|
|
|
if($flush) { |