src/AppBundle/EventListener/ArtikelOnlineEventListener.php line 39

Open in your IDE?
  1. <?php
  2. namespace AppBundle\EventListener;
  3. use AppBundle\Service\Galaxus\GalaxusTitleService;
  4. use Pimcore\Event\Model\ElementEventInterface;
  5. use Pimcore\Model\DataObject\Artikelonline;
  6. use Symfony\Component\Messenger\MessageBusInterface;
  7. class ArtikelOnlineEventListener extends DataObjectEventListener
  8. {
  9.     const PIMCORE_DATA_OBJECT_CLASS_PATH Artikelonline::class;
  10.     protected $object;
  11.     private $galaxusTitleService;
  12.     public function __construct(MessageBusInterface $messageBus){
  13.         parent::__construct($messageBus);
  14.         $this->galaxusTitleService = new GalaxusTitleService;
  15.     }
  16.     /**
  17.      * @param ElementEventInterface $event
  18.      * @return void
  19.      * @throws \Doctrine\DBAL\DBALException
  20.      */
  21.     public function onObjectPreUpdate(ElementEventInterface $event): void {
  22.         // Not artikelonline?
  23.         if(!$this->eventBelongsToThisClass($event)){
  24.             return;
  25.         }
  26.         $this->galaxusTitleService->handleGalaxusTitleUpdate($this->object);
  27.     }
  28.     /**
  29.      * @param ElementEventInterface $event
  30.      * @return void
  31.      * @throws \Doctrine\DBAL\DBALException
  32.      */
  33.     public function onObjectPreSave(ElementEventInterface $event): void {
  34.         // Not artikelonline?
  35.         if(!$this->eventBelongsToThisClass($event)){
  36.             return;
  37.         }
  38.         $this->galaxusTitleService->handleGalaxusTitleUpdate($this->object);
  39.     }
  40. }