class ConfigSnapshotSubscriber

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php \Drupal\Core\EventSubscriber\ConfigSnapshotSubscriber
  2. 10 core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php \Drupal\Core\EventSubscriber\ConfigSnapshotSubscriber
  3. 9 core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php \Drupal\Core\EventSubscriber\ConfigSnapshotSubscriber
  4. 8.9.x core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php \Drupal\Core\EventSubscriber\ConfigSnapshotSubscriber

Create a snapshot when config is imported.

Hierarchy

  • class \Drupal\Core\EventSubscriber\ConfigSnapshotSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of ConfigSnapshotSubscriber

1 string reference to 'ConfigSnapshotSubscriber'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses ConfigSnapshotSubscriber
config_snapshot_subscriber in core/core.services.yml
Drupal\Core\EventSubscriber\ConfigSnapshotSubscriber

File

core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php, line 14

Namespace

Drupal\Core\EventSubscriber
View source
class ConfigSnapshotSubscriber implements EventSubscriberInterface {
  
  /**
   * Constructs the ConfigSnapshotSubscriber object.
   *
   * @param \Drupal\Core\Config\ConfigManagerInterface $configManager
   *   The configuration manager.
   * @param \Drupal\Core\Config\StorageInterface $sourceStorage
   *   The source storage used to discover configuration changes.
   * @param \Drupal\Core\Config\StorageInterface $snapshotStorage
   *   The snapshot storage used to write configuration changes.
   */
  public function __construct(protected ConfigManagerInterface $configManager, protected StorageInterface $sourceStorage, protected StorageInterface $snapshotStorage) {
  }
  
  /**
   * Creates a config snapshot.
   *
   * @param \Drupal\Core\Config\ConfigImporterEvent $event
   *   The Event to process.
   */
  public function onConfigImporterImport(ConfigImporterEvent $event) {
    $this->configManager
      ->createSnapshot($this->sourceStorage, $this->snapshotStorage);
  }
  
  /**
   * Registers the methods in this class that should be listeners.
   *
   * @return array
   *   An array of event listener definitions.
   */
  public static function getSubscribedEvents() : array {
    $events[ConfigEvents::IMPORT][] = [
      'onConfigImporterImport',
      40,
    ];
    return $events;
  }

}

Members

Title Sort descending Modifiers Object type Summary
ConfigSnapshotSubscriber::getSubscribedEvents public static function Registers the methods in this class that should be listeners.
ConfigSnapshotSubscriber::onConfigImporterImport public function Creates a config snapshot.
ConfigSnapshotSubscriber::__construct public function Constructs the ConfigSnapshotSubscriber object.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.