You are here

class ConfigurationSubscriber in Facets 8

Config subscriber for facet delete.

Hierarchy

  • class \Drupal\facets\EventSubscriber\ConfigurationSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of ConfigurationSubscriber

1 string reference to 'ConfigurationSubscriber'
facets.services.yml in ./facets.services.yml
facets.services.yml
1 service uses ConfigurationSubscriber
facets.configuration_subscriber in ./facets.services.yml
Drupal\facets\EventSubscriber\ConfigurationSubscriber

File

src/EventSubscriber/ConfigurationSubscriber.php, line 13

Namespace

Drupal\facets\EventSubscriber
View source
class ConfigurationSubscriber implements EventSubscriberInterface {

  /**
   * Drupal core's block manager.
   *
   * @var \Drupal\Core\Block\BlockManagerInterface
   */
  protected $blockManager;

  /**
   * Create an instance of the class.
   *
   * @param \Drupal\Core\Block\BlockManagerInterface $block_manager
   *   Core's block manager.
   */
  public function __construct(BlockManagerInterface $block_manager) {
    $this->blockManager = $block_manager;
  }

  /**
   * Reacts to a config delete event to clear the required caches.
   *
   * @param \Drupal\Core\Config\ConfigCrudEvent $event
   *   The config delete event.
   */
  public function onConfigDelete(ConfigCrudEvent $event) {
    $config = $event
      ->getConfig();
    if (strpos($config
      ->getName(), 'facets') !== FALSE) {
      $this->blockManager
        ->clearCachedDefinitions();
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[ConfigEvents::DELETE][] = [
      'onConfigDelete',
      50,
    ];
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigurationSubscriber::$blockManager protected property Drupal core's block manager.
ConfigurationSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
ConfigurationSubscriber::onConfigDelete public function Reacts to a config delete event to clear the required caches.
ConfigurationSubscriber::__construct public function Create an instance of the class.