|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
-
- namespace Lc\CaracoleBundle\EventSubscriber\Product;
-
- use Doctrine\ORM\EntityManagerInterface;
-
- use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityUpdatedEvent;
- use Lc\CaracoleBundle\Builder\Order\OrderShopBuilder;
- use Lc\CaracoleBundle\Container\Product\ProductContainer;
- use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
- use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
- use Lc\CaracoleBundle\Model\Product\ProductInterface;
- use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface;
- use Lc\SovBundle\Event\EntityManager\EntityManagerEvent;
- use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-
- class UpdateProductfamilyAfterFlushEventSubscriber implements EventSubscriberInterface
- {
- protected EntityManagerInterface $em;
- protected ProductFamilyContainer $productFamilyContainer;
- protected ProductContainer $productContainer;
- protected OrderShopBuilder $orderShopBuilder;
-
- public function __construct(EntityManagerInterface $entityManager, ProductFamilyContainer $productFamilyContainer, ProductContainer $productContainer, OrderShopBuilder $orderShopBuilder)
- {
- $this->em = $entityManager;
- $this->productFamilyContainer = $productFamilyContainer;
- $this->productContainer = $productContainer;
- $this->orderShopBuilder = $orderShopBuilder;
- }
-
- public static function getSubscribedEvents()
- {
- return [
- AfterEntityUpdatedEvent::class => ['processAfterFlushProductFamily'],
- ];
- }
-
- public function processAfterFlushProductFamily(AfterEntityUpdatedEvent $event)
- {
- $entity = $event->getEntityInstance();
- if ($entity instanceof ProductFamilyInterface) {
- $this->orderShopBuilder->updatePriceByProductFamily($entity);
- }
- }
- }
|