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
1 <?php
2
3 namespace Drupal\woot\EventSubscriber;
4
5 use Drupal\Core\Config\ConfigEvents;
6 use Drupal\Core\Config\ConfigImporterEvent;
7 use Drupal\Core\Config\ConfigImportValidateEventSubscriberBase;
8
9 /**
10  * Subscribes to Symfony events and maps them to Rules events.
11  */
12 class ConfigSubscriber extends ConfigImportValidateEventSubscriberBase
13 {
14
15   /**
16    * {@inheritdoc}
17    */
18     public static function getSubscribedEvents()
19     {
20         $events = [];
21
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';
28         }
29
30         return $events;
31     }
32
33   /**
34    * {@inheritdoc}
35    */
36     public function onConfigImporterValidate(ConfigImporterEvent $event)
37     {
38         // Always log an error.
39         $importer = $event->getConfigImporter();
40         $importer->logError($this->t('woot config error'));
41     }
42 }