|
|
|
|
|
|
|
|
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; |
|
|
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; |
|
|
use Lc\CaracoleBundle\Model\Section\SectionInterface; |
|
|
use Lc\CaracoleBundle\Model\Section\SectionInterface; |
|
|
use Lc\CaracoleBundle\Repository\Product\ProductFamilySectionPropertyStore; |
|
|
use Lc\CaracoleBundle\Repository\Product\ProductFamilySectionPropertyStore; |
|
|
|
|
|
use Lc\CaracoleBundle\Solver\Product\ProductFamilySectionPropertySolver; |
|
|
|
|
|
|
|
|
class ProductFamilySectionPropertyBuilder |
|
|
class ProductFamilySectionPropertyBuilder |
|
|
{ |
|
|
{ |
|
|
protected EntityManagerInterface $entityManager; |
|
|
protected EntityManagerInterface $entityManager; |
|
|
protected ProductFamilySectionPropertyFactory $productFamilySectionPropertyFactory; |
|
|
protected ProductFamilySectionPropertyFactory $productFamilySectionPropertyFactory; |
|
|
protected ProductFamilySectionPropertyStore $productFamilySectionPropertyStore; |
|
|
|
|
|
|
|
|
protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver; |
|
|
|
|
|
|
|
|
public function __construct( |
|
|
public function __construct( |
|
|
EntityManagerInterface $entityManager, |
|
|
EntityManagerInterface $entityManager, |
|
|
ProductFamilySectionPropertyFactory $productFamilySectionPropertyFactory, |
|
|
ProductFamilySectionPropertyFactory $productFamilySectionPropertyFactory, |
|
|
ProductFamilySectionPropertyStore $productFamilySectionPropertyStore |
|
|
|
|
|
|
|
|
ProductFamilySectionPropertySolver $productFamilySectionPropertySolver |
|
|
) { |
|
|
) { |
|
|
$this->entityManager = $entityManager; |
|
|
$this->entityManager = $entityManager; |
|
|
$this->productFamilySectionPropertyFactory = $productFamilySectionPropertyFactory; |
|
|
$this->productFamilySectionPropertyFactory = $productFamilySectionPropertyFactory; |
|
|
$this->productFamilySectionPropertyStore = $productFamilySectionPropertyStore; |
|
|
|
|
|
|
|
|
$this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function enable(ProductFamilyInterface $productFamily, SectionInterface $section, bool $flush = true): void |
|
|
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) { |
|
|
if (!$productFamilySectionProperty->getStatus()) { |
|
|
if (!$productFamilySectionProperty->getStatus()) { |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
$productFamilySectionProperty = $this->productFamilySectionPropertyFactory->create($section, $productFamily); |
|
|
$productFamilySectionProperty = $this->productFamilySectionPropertyFactory->create($section, $productFamily); |
|
|
$productFamilySectionProperty->setStatus(1); |
|
|
$productFamilySectionProperty->setStatus(1); |
|
|
|
|
|
$productFamily->addProductFamilySectionProperty($productFamilySectionProperty); |
|
|
$this->entityManager->create($productFamilySectionProperty); |
|
|
$this->entityManager->create($productFamilySectionProperty); |
|
|
|
|
|
$this->entityManager->update($productFamily); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if($flush) { |
|
|
if($flush) { |