class ConfigSnapshotSubscriber in Drupal 8
Same name and namespace in other branches
- 9 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
File
- core/
lib/ Drupal/ Core/ EventSubscriber/ ConfigSnapshotSubscriber.php, line 14
Namespace
Drupal\Core\EventSubscriberView source
class ConfigSnapshotSubscriber implements EventSubscriberInterface {
/**
* The configuration manager.
*
* @var \Drupal\Core\Config\ConfigManagerInterface
*/
protected $configManager;
/**
* 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 \Drupal\Core\Config\StorageInterface $source_storage
* The source storage used to discover configuration changes.
* @param \Drupal\Core\Config\StorageInterface $snapshot_storage
* The snapshot storage used to write configuration changes.
*/
public function __construct(ConfigManagerInterface $config_manager, StorageInterface $source_storage, StorageInterface $snapshot_storage) {
$this->configManager = $config_manager;
$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) {
$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() {
$events[ConfigEvents::IMPORT][] = [
'onConfigImporterImport',
40,
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigSnapshotSubscriber:: |
protected | property | The configuration manager. | |
ConfigSnapshotSubscriber:: |
protected | property | The snapshot storage used to write configuration changes. | |
ConfigSnapshotSubscriber:: |
protected | property | The source storage used to discover configuration changes. | |
ConfigSnapshotSubscriber:: |
public static | function | Registers the methods in this class that should be listeners. | |
ConfigSnapshotSubscriber:: |
public | function | Creates a config snapshot. | |
ConfigSnapshotSubscriber:: |
public | function | Constructs the ConfigSnapshotSubscriber object. |