entityManager = $entityManager; $this->productFamilySectionPropertyFactory = $productFamilySectionPropertyFactory; $this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver; } public function enable(ProductFamilyInterface $productFamily, SectionInterface $section, bool $flush = true): void { $productFamilySectionProperty = $this->productFamilySectionPropertySolver->getProductFamilySectionProperty($productFamily, $section); if ($productFamilySectionProperty) { if (!$productFamilySectionProperty->getStatus()) { $productFamilySectionProperty->setStatus(1); $this->entityManager->update($productFamilySectionProperty); } } else { $productFamilySectionProperty = $this->productFamilySectionPropertyFactory->create($section, $productFamily); $productFamilySectionProperty->setStatus(1); $productFamily->addProductFamilySectionProperty($productFamilySectionProperty); $this->entityManager->create($productFamilySectionProperty); $this->entityManager->update($productFamily); } if($flush) { $this->entityManager->flush(); } } public function disable(ProductFamilyInterface $productFamily, SectionInterface $section, bool $flush = true): void { $productFamilySectionProperty = $this->productFamilySectionPropertySolver->getProductFamilySectionProperty($productFamily, $section); if ($productFamilySectionProperty) { $productFamilySectionProperty->setStatus(0); $this->entityManager->update($productFamilySectionProperty); } if($flush) { $this->entityManager->flush(); } } }