vendor/pimcore/data-hub-simple-rest/src/EventSubscriber/ConfigurationEventSubscriber.php line 48

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under following license:
  6.  * - Pimcore Commercial License (PCL)
  7.  *
  8.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  9.  *  @license    http://www.pimcore.org/license     PCL
  10.  */
  11. namespace Pimcore\Bundle\DataHubSimpleRestBundle\EventSubscriber;
  12. use Pimcore\Bundle\DataHubBundle\Configuration;
  13. use Pimcore\Bundle\DataHubBundle\Event\ConfigurationEvents;
  14. use Pimcore\Bundle\DataHubSimpleRestBundle\Service\IndexService;
  15. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  16. use Symfony\Component\EventDispatcher\GenericEvent;
  17. class ConfigurationEventSubscriber implements EventSubscriberInterface
  18. {
  19.     /**
  20.      * @var IndexService
  21.      */
  22.     protected $indexService;
  23.     /**
  24.      * @param IndexService $indexService
  25.      */
  26.     public function __construct(IndexService $indexService)
  27.     {
  28.         $this->indexService $indexService;
  29.     }
  30.     public static function getSubscribedEvents()
  31.     {
  32.         return [
  33.             ConfigurationEvents::CONFIGURATION_POST_DELETE => 'postDelete'
  34.         ];
  35.     }
  36.     /**
  37.      * @param GenericEvent $event
  38.      *
  39.      * @throws \Doctrine\DBAL\DBALException
  40.      */
  41.     public function postDelete(GenericEvent $event)
  42.     {
  43.         /**
  44.          * @var $config Configuration
  45.          */
  46.         $config $event->getSubject();
  47.         //TODO move this to config once more similar adapters are implemented
  48.         if (in_array($config->getType(), ['simpleRest''ciHub'])) {
  49.             $this->indexService->cleanupIndicesForConfig($config->getName());
  50.         }
  51.     }
  52. }