src/Essesolutions/AdminBundle/EventListener/DataObject/DataHookListener.php line 38

Open in your IDE?
  1. <?php
  2. namespace App\Essesolutions\AdminBundle\EventListener\DataObject;
  3. use App\Essesolutions\AdminBundle\Service\CopyReferencedValuesServiceInterface;
  4. use Pimcore\Event\DataObjectEvents;
  5. use Pimcore\Event\Model\DataObjectEvent;
  6. use Pimcore\Model\DataObject\Concrete;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. class DataHookListener implements EventSubscriberInterface
  9. {
  10.     private CopyReferencedValuesServiceInterface $copyReferencedValuesService;
  11.     
  12.     /**
  13.      * @param CopyReferencedValuesServiceInterface $copyReferencedValuesService
  14.      */
  15.     public function __construct(
  16.         CopyReferencedValuesServiceInterface $copyReferencedValuesService
  17.     )
  18.     {
  19.         $this->copyReferencedValuesService $copyReferencedValuesService;
  20.     }
  21.     
  22.     /** {@inheritDoc} */
  23.     public static function getSubscribedEvents()
  24.     {
  25.         return [
  26.             DataObjectEvents::POST_UPDATE => 'onDataObjectSave'
  27.         ];
  28.     }
  29.     
  30.     /**
  31.      * @param DataObjectEvent $dataObjectEvent
  32.      *
  33.      * @return void
  34.      */
  35.     public function onDataObjectSave(DataObjectEvent $dataObjectEvent)
  36.     {
  37.         if (!$dataObjectEvent->getObject() instanceof Concrete) {
  38.             return;
  39.         }
  40.         
  41.         $this->copyReferencedValuesService->exec($dataObjectEvent->getObject());
  42.     }
  43. }