src/EventSubscriber/Article/ArticleSubscriber.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber\Article;
  3. use App\Event\Article\ArticlePumpUpdateEvent;
  4. use App\Service\Articles\ArticlePumpService;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class ArticleSubscriber implements EventSubscriberInterface
  8. {
  9.     private $em;
  10.     private ArticlePumpService $articlePumpService;
  11.     public function __construct(EntityManagerInterface $emArticlePumpService $articlePumpService)
  12.     {
  13.         $this->em                 $em;
  14.         $this->articlePumpService $articlePumpService;
  15.     }
  16.     public static function getSubscribedEvents()
  17.     {
  18.         return [
  19.            ArticlePumpUpdateEvent::class => ['onUpdatePumpArticle'100],
  20.         ];
  21.     }
  22.     public function onUpdatePumpArticle(ArticlePumpUpdateEvent $event)
  23.     {
  24.         $article     $event->getArticle();
  25.         $this->em->refresh($article);
  26.         $this->articlePumpService->majArticlePump($article$event->getOutput(), $event->getMouvementStock());
  27.     }
  28. }