You are here

class LibrariesConfigSubscriber in Libraries API 8.3

Reacts to configuration changes of the 'libraries.settings' configuration.

Hierarchy

  • class \Drupal\libraries\Config\LibrariesConfigSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of LibrariesConfigSubscriber

1 string reference to 'LibrariesConfigSubscriber'
libraries.services.yml in ./libraries.services.yml
libraries.services.yml
1 service uses LibrariesConfigSubscriber
libraries.config_subscriber in ./libraries.services.yml
Drupal\libraries\Config\LibrariesConfigSubscriber

File

src/Config/LibrariesConfigSubscriber.php, line 13

Namespace

Drupal\libraries\Config
View source
class LibrariesConfigSubscriber implements EventSubscriberInterface {

  /**
   * The service container.
   *
   * @var \Symfony\Component\DependencyInjection\ContainerInterface
   */
  protected $container;

  /**
   * Constructs a Libraries API configuration subscriber.
   *
   * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
   *   The service container.
   */
  public function __construct(ContainerInterface $container) {
    $this->container = $container;
  }

  /**
   * Unsets the definition discovery service when its configuration changes.
   *
   * @param \Drupal\Core\Config\ConfigCrudEvent $event
   *   The configuration event.
   */
  public function onConfigSave(ConfigCrudEvent $event) {
    if ($event
      ->getConfig()
      ->getName() === 'libraries.settings' && $event
      ->isChanged('definition')) {
      $this->container
        ->set('libraries.definition.discovery', NULL);
    }
  }

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

}

Members

Namesort descending Modifiers Type Description Overrides
LibrariesConfigSubscriber::$container protected property The service container.
LibrariesConfigSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
LibrariesConfigSubscriber::onConfigSave public function Unsets the definition discovery service when its configuration changes.
LibrariesConfigSubscriber::__construct public function Constructs a Libraries API configuration subscriber.