You are here

class ConfigSubscriber in Menu Link Weight 8

Same name and namespace in other branches
  1. 8.2 src/EventSubscriber/ConfigSubscriber.php \Drupal\menu_link_weight\EventSubscriber\ConfigSubscriber

Hierarchy

  • class \Drupal\menu_link_weight\EventSubscriber\ConfigSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of ConfigSubscriber

1 string reference to 'ConfigSubscriber'
menu_link_weight.services.yml in ./menu_link_weight.services.yml
menu_link_weight.services.yml
1 service uses ConfigSubscriber
menu_link_weight.bc_config_subscriber in ./menu_link_weight.services.yml
Drupal\menu_link_weight\EventSubscriber\ConfigSubscriber

File

src/EventSubscriber/ConfigSubscriber.php, line 10

Namespace

Drupal\menu_link_weight\EventSubscriber
View source
class ConfigSubscriber implements EventSubscriberInterface {

  /**
   * The Drupal Kernel.
   *
   * @var \Drupal\Core\DrupalKernelInterface
   */
  protected $kernel;

  /**
   * ConfigSubscriber constructor.
   *
   * @param \Drupal\Core\DrupalKernelInterface $kernel
   *   The Drupal Kernel.
   */
  public function __construct(DrupalKernelInterface $kernel) {
    $this->kernel = $kernel;
  }

  /**
   * Causes the container to be rebuilt on the next request.
   *
   * @param ConfigCrudEvent $event
   *   The configuration event.
   */
  public function onConfigSave(ConfigCrudEvent $event) {
    $saved_config = $event
      ->getConfig();
    if ($saved_config
      ->getName() == 'menu_link_weight.settings' && $event
      ->isChanged('menu_parent_form_selector')) {
      $this->kernel
        ->invalidateContainer();
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[ConfigEvents::SAVE][] = [
      'onConfigSave',
      0,
    ];
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigSubscriber::$kernel protected property The Drupal Kernel.
ConfigSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
ConfigSubscriber::onConfigSave public function Causes the container to be rebuilt on the next request.
ConfigSubscriber::__construct public function ConfigSubscriber constructor.