Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / drush / drush / tests / resources / modules / d8 / woot / src / EventSubscriber / ConfigSubscriber.php
diff --git a/vendor/drush/drush/tests/resources/modules/d8/woot/src/EventSubscriber/ConfigSubscriber.php b/vendor/drush/drush/tests/resources/modules/d8/woot/src/EventSubscriber/ConfigSubscriber.php
new file mode 100644 (file)
index 0000000..b13121f
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+
+namespace Drupal\woot\EventSubscriber;
+
+use Drupal\Core\Config\ConfigEvents;
+use Drupal\Core\Config\ConfigImporterEvent;
+use Drupal\Core\Config\ConfigImportValidateEventSubscriberBase;
+
+/**
+ * Subscribes to Symfony events and maps them to Rules events.
+ */
+class ConfigSubscriber extends ConfigImportValidateEventSubscriberBase
+{
+
+  /**
+   * {@inheritdoc}
+   */
+    public static function getSubscribedEvents()
+    {
+        $events = [];
+
+        // In this example, we would use information from the State API to determine
+        // what events we should subscribe to. Suffice it to say we trust that the
+        // State API works correctly, so we're only going to check if the service is
+        // available here to make our point.
+        if (\Drupal::hasService('state')) {
+            $events[ConfigEvents::IMPORT_VALIDATE][] = 'onConfigImporterValidate';
+        }
+
+        return $events;
+    }
+
+  /**
+   * {@inheritdoc}
+   */
+    public function onConfigImporterValidate(ConfigImporterEvent $event)
+    {
+        // Always log an error.
+        $importer = $event->getConfigImporter();
+        $importer->logError($this->t('woot config error'));
+    }
+}