The configuration system fires events at certain points when saving or deleting configuration and in the import process. The names for these have been harcoded strings across different parts of core. A new Drupal\Core\Config\Config\ConfigEvents class was introduced to define related constants for event names. The base ConfigEvent class was renamed ConfigCrudEvent. When renaming configuration, no event was fired. Now this action fires Drupal\Core\Config\ConfigRenameEvent.
Finally, a new changed() method was added on the ConfigCrudEvent to make it easy to tell if a value was changed. For example, if you want to inspect if a save event changed the language of a configuration file, use if ($event->changed('langcode')) { ... } in your event subscriber.
Before
use Drupal\Core\Config\ConfigEvent;
class ConfigSubscriber implements EventSubscriberInterface {
public function onConfigSave(ConfigEvent $event) {
// Do something.
}
static function getSubscribedEvents() {
$events['config.save'][] = array('onConfigSave', 0);
return $events;
}
}
After
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
class ConfigSubscriber implements EventSubscriberInterface {
public function onConfigSave(ConfigCrudEvent $event) {
// Do something.
}
static function getSubscribedEvents() {
$events[ConfigEvents::SAVE][] = array('onConfigSave', 0);
return $events;
}
}
\Drupal\Core\Config\ConfigEvents contains class constants for the SAVE, DELETE, RENAME config CRUD events; MODULE_OVERRIDES for the override event; and VALIDATE and IMPORT for the config import events.