vendor/pimcore/customer-management-framework-bundle/src/Event/PimcoreElementRemovalListener.php line 84

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Commercial License (PCL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  *  @license    http://www.pimcore.org/license     GPLv3 and PCL
  13.  */
  14. namespace CustomerManagementFrameworkBundle\Event;
  15. use CustomerManagementFrameworkBundle\SegmentAssignment\SegmentAssigner\SegmentAssignerInterface;
  16. use CustomerManagementFrameworkBundle\SegmentAssignment\TypeMapper\TypeMapperInterface;
  17. use Pimcore\Event\Model\ElementEventInterface;
  18. /**
  19.  * Class PimcoreElementRemovalListener
  20.  *
  21.  * @package CustomerManagementFrameworkBundle\Event
  22.  */
  23. class PimcoreElementRemovalListener implements PimcoreElementRemovalListenerInterface
  24. {
  25.     /**
  26.      * @var SegmentAssignerInterface
  27.      */
  28.     private $segmentAssigner null;
  29.     /**
  30.      * @var TypeMapperInterface
  31.      */
  32.     private $typeMapper null;
  33.     /**
  34.      * @param SegmentAssignerInterface $segmentAssigner
  35.      * @param TypeMapperInterface $typeMapper
  36.      */
  37.     public function __construct(SegmentAssignerInterface $segmentAssignerTypeMapperInterface $typeMapper)
  38.     {
  39.         $this->setSegmentAssigner($segmentAssigner);
  40.         $this->setTypeMapper($typeMapper);
  41.     }
  42.     /**
  43.      * @return SegmentAssignerInterface
  44.      */
  45.     public function getSegmentAssigner(): SegmentAssignerInterface
  46.     {
  47.         return $this->segmentAssigner;
  48.     }
  49.     /**
  50.      * @param SegmentAssignerInterface $segmentAssigner
  51.      */
  52.     public function setSegmentAssigner(SegmentAssignerInterface $segmentAssigner)
  53.     {
  54.         $this->segmentAssigner $segmentAssigner;
  55.     }
  56.     /**
  57.      * @return TypeMapperInterface
  58.      */
  59.     public function getTypeMapper(): TypeMapperInterface
  60.     {
  61.         return $this->typeMapper;
  62.     }
  63.     /**
  64.      * @param TypeMapperInterface $typeMapper
  65.      */
  66.     public function setTypeMapper(TypeMapperInterface $typeMapper)
  67.     {
  68.         $this->typeMapper $typeMapper;
  69.     }
  70.     /**
  71.      * @inheritdoc
  72.      */
  73.     public function onPostDelete(ElementEventInterface $event)
  74.     {
  75.         $id $event->getElement()->getId();
  76.         $type $this->getTypeMapper()->getTypeStringByObject($event->getElement());
  77.         $this->getSegmentAssigner()->removeElementById($id$type);
  78.     }
  79. }