3 namespace Drupal\libraries\Config;
5 use Drupal\Core\Config\ConfigCrudEvent;
6 use Drupal\Core\Config\ConfigEvents;
7 use Symfony\Component\DependencyInjection\ContainerInterface;
8 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
11 * Reacts to configuration changes of the 'libraries.settings' configuration.
13 class LibrariesConfigSubscriber implements EventSubscriberInterface {
16 * The service container.
18 * @var \Symfony\Component\DependencyInjection\ContainerInterface
23 * Constructs a Libraries API configuration subscriber.
25 * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
26 * The service container.
28 public function __construct(ContainerInterface $container) {
29 $this->container = $container;
33 * Unsets the definition discovery service when its configuration changes.
35 * @param \Drupal\Core\Config\ConfigCrudEvent $event
36 * The configuration event.
38 public function onConfigSave(ConfigCrudEvent $event) {
39 if (($event->getConfig()->getName() === 'libraries.settings') && $event->isChanged('definition')) {
40 $this->container->set('libraries.definition.discovery', NULL);
47 public static function getSubscribedEvents() {
48 return [ConfigEvents::SAVE => 'onConfigSave'];