forked from daggerhart/drupal8_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigEventsSubscriber.php
More file actions
51 lines (44 loc) · 1.23 KB
/
ConfigEventsSubscriber.php
File metadata and controls
51 lines (44 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Drupal\custom_events\EventSubscriber;
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Class EntityTypeSubscriber.
*
* @package Drupal\custom_events\EventSubscriber
*/
class ConfigEventsSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*
* @return array
* The event names to listen for, and the methods that should be executed.
*/
public static function getSubscribedEvents() {
return [
ConfigEvents::SAVE => 'configSave',
ConfigEvents::DELETE => 'configDelete',
];
}
/**
* React to a config object being saved.
*
* @param \Drupal\Core\Config\ConfigCrudEvent $event
* Config crud event.
*/
public function configSave(ConfigCrudEvent $event) {
$config = $event->getConfig();
drupal_set_message('Saved config: ' . $config->getName());
}
/**
* React to a config object being deleted.
*
* @param \Drupal\Core\Config\ConfigCrudEvent $event
* Config crud event.
*/
public function configDelete(ConfigCrudEvent $event) {
$config = $event->getConfig();
drupal_set_message('Deleted config: ' . $config->getName());
}
}