<?php
namespace AppBundle\EventListener;
use AppBundle\Service\Galaxus\GalaxusTitleService;
use Pimcore\Event\Model\ElementEventInterface;
use Pimcore\Model\DataObject\Artikelonline;
use Symfony\Component\Messenger\MessageBusInterface;
class ArtikelOnlineEventListener extends DataObjectEventListener
{
const PIMCORE_DATA_OBJECT_CLASS_PATH = Artikelonline::class;
protected $object;
private $galaxusTitleService;
public function __construct(MessageBusInterface $messageBus){
parent::__construct($messageBus);
$this->galaxusTitleService = new GalaxusTitleService;
}
/**
* @param ElementEventInterface $event
* @return void
* @throws \Doctrine\DBAL\DBALException
*/
public function onObjectPreUpdate(ElementEventInterface $event): void {
// Not artikelonline?
if(!$this->eventBelongsToThisClass($event)){
return;
}
$this->galaxusTitleService->handleGalaxusTitleUpdate($this->object);
}
/**
* @param ElementEventInterface $event
* @return void
* @throws \Doctrine\DBAL\DBALException
*/
public function onObjectPreSave(ElementEventInterface $event): void {
// Not artikelonline?
if(!$this->eventBelongsToThisClass($event)){
return;
}
$this->galaxusTitleService->handleGalaxusTitleUpdate($this->object);
}
}