class ConfigSnapshotSubscriber

Create a snapshot when config is imported.

Hierarchy

Expanded class hierarchy of ConfigSnapshotSubscriber

1 string reference to 'ConfigSnapshotSubscriber'
core.services.yml in drupal/core/core.services.yml
drupal/core/core.services.yml

File

drupal/core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php, line 18
Contains \Drupal\Core\EventSubscriber\ConfigSnapshotSubscriber.

Namespace

Drupal\Core\EventSubscriber
View source
class ConfigSnapshotSubscriber implements EventSubscriberInterface {

  /**
   * The source storage used to discover configuration changes.
   *
   * @var \Drupal\Core\Config\StorageInterface
   */
  protected $sourceStorage;

  /**
   * The snapshot storage used to write configuration changes.
   *
   * @var \Drupal\Core\Config\StorageInterface
   */
  protected $snapshotStorage;

  /**
   * Constructs the ConfigSnapshotSubscriber object.
   *
   * @param StorageInterface $source_storage
   *   The source storage used to discover configuration changes.
   * @param StorageInterface $snapshot_storage
   *   The snapshot storage used to write configuration changes.
   */
  public function __construct(StorageInterface $source_storage, StorageInterface $snapshot_storage) {
    $this->sourceStorage = $source_storage;
    $this->snapshotStorage = $snapshot_storage;
  }

  /**
   * Creates a config snapshot.
   *
   * @param \Drupal\Core\Config\ConfigImporterEvent $event
   *   The Event to process.
   */
  public function onConfigImporterImport(ConfigImporterEvent $event) {
    config_import_create_snapshot($this->sourceStorage, $this->snapshotStorage);
  }

  /**
   * Registers the methods in this class that should be listeners.
   *
   * @return array
   *   An array of event listener definitions.
   */
  static function getSubscribedEvents() {
    $events['config.importer.import'][] = array(
      'onConfigImporterImport',
      40,
    );
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigSnapshotSubscriber::$snapshotStorage protected property The snapshot storage used to write configuration changes.
ConfigSnapshotSubscriber::$sourceStorage protected property The source storage used to discover configuration changes.
ConfigSnapshotSubscriber::getSubscribedEvents static function Registers the methods in this class that should be listeners. Overrides EventSubscriberInterface::getSubscribedEvents
ConfigSnapshotSubscriber::onConfigImporterImport public function Creates a config snapshot.
ConfigSnapshotSubscriber::__construct public function Constructs the ConfigSnapshotSubscriber object.