Change record status: 
Project: 
Introduced in branch: 
10.3.x
Introduced in version: 
10.3.0
Description: 

When config is saved, deleted, or renamed, the following events are dispatched:

  • \Drupal\Core\Config\ConfigEvents::SAVE
  • \Drupal\Core\Config\ConfigEvents::DELETE
  • \Drupal\Core\Config\ConfigEvents::RENAME

However, these events are only consistently dispatched for config that is saved in the default collection (\Drupal\Core\Config\StorageInterface::DEFAULT_COLLECTION) of active config. In some cases, partial config is saved in collections other than the default one; config translations are the main example in core. In such cases, these events might not be dispatched; other events might be dispatched instead, depending on which module is responsible for the collection. In the case of config translation, for example, the Language module dispatches the \Drupal\language\Config\LanguageConfigOverrideEvents::SAVE_OVERRIDE and \Drupal\language\Config\LanguageConfigOverrideEvents::DELETE_OVERRIDE events. But it varies from module to module.

Drupal core now has a new set of generic events for config that is part of a non-default collection. These events largely mirror the ones in the ConfigEvents class:

  • Drupal\Core\Config\ConfigCollectionEvents::SAVE_IN_COLLECTION
  • Drupal\Core\Config\ConfigCollectionEvents::DELETE_IN_COLLECTION
  • Drupal\Core\Config\ConfigCollectionEvents::RENAME_IN_COLLECTION

The difference is that these are all specifically dispatched for config -- which might be partial -- that lives in a non-default collection. If you specifically need to react when config that lives in a non-default collection is modified, subscribe to these events.

On the other hand, if you only care about config in the default collection -- which is the case 99% of the time -- you should continue using the existing ConfigEvents events.

Impacts: 
Module developers
Site templates, recipes and distribution developers