3 namespace Drupal\woot\EventSubscriber;
5 use Drupal\Core\Config\ConfigEvents;
6 use Drupal\Core\Config\ConfigImporterEvent;
7 use Drupal\Core\Config\ConfigImportValidateEventSubscriberBase;
10 * Subscribes to Symfony events and maps them to Rules events.
12 class ConfigSubscriber extends ConfigImportValidateEventSubscriberBase
18 public static function getSubscribedEvents()
22 // In this example, we would use information from the State API to determine
23 // what events we should subscribe to. Suffice it to say we trust that the
24 // State API works correctly, so we're only going to check if the service is
25 // available here to make our point.
26 if (\Drupal::hasService('state')) {
27 $events[ConfigEvents::IMPORT_VALIDATE][] = 'onConfigImporterValidate';
36 public function onConfigImporterValidate(ConfigImporterEvent $event)
38 // Always log an error.
39 $importer = $event->getConfigImporter();
40 $importer->logError($this->t('woot config error'));