Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 7a779792577d |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Core\EventSubscriber; | |
4 | |
5 use Drupal\Core\Config\ConfigEvents; | |
6 use Drupal\Core\Config\ConfigManagerInterface; | |
7 use Drupal\Core\Config\StorageInterface; | |
8 use Drupal\Core\Config\ConfigImporterEvent; | |
9 use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |
10 | |
11 /** | |
12 * Create a snapshot when config is imported. | |
13 */ | |
14 class ConfigSnapshotSubscriber implements EventSubscriberInterface { | |
15 | |
16 /** | |
17 * The configuration manager. | |
18 * | |
19 * @var \Drupal\Core\Config\ConfigManagerInterface | |
20 */ | |
21 protected $configManager; | |
22 | |
23 /** | |
24 * The source storage used to discover configuration changes. | |
25 * | |
26 * @var \Drupal\Core\Config\StorageInterface | |
27 */ | |
28 protected $sourceStorage; | |
29 | |
30 /** | |
31 * The snapshot storage used to write configuration changes. | |
32 * | |
33 * @var \Drupal\Core\Config\StorageInterface | |
34 */ | |
35 protected $snapshotStorage; | |
36 | |
37 /** | |
38 * Constructs the ConfigSnapshotSubscriber object. | |
39 * | |
40 * @param StorageInterface $source_storage | |
41 * The source storage used to discover configuration changes. | |
42 * @param StorageInterface $snapshot_storage | |
43 * The snapshot storage used to write configuration changes. | |
44 */ | |
45 public function __construct(ConfigManagerInterface $config_manager, StorageInterface $source_storage, StorageInterface $snapshot_storage) { | |
46 $this->configManager = $config_manager; | |
47 $this->sourceStorage = $source_storage; | |
48 $this->snapshotStorage = $snapshot_storage; | |
49 } | |
50 | |
51 /** | |
52 * Creates a config snapshot. | |
53 * | |
54 * @param \Drupal\Core\Config\ConfigImporterEvent $event | |
55 * The Event to process. | |
56 */ | |
57 public function onConfigImporterImport(ConfigImporterEvent $event) { | |
58 $this->configManager->createSnapshot($this->sourceStorage, $this->snapshotStorage); | |
59 } | |
60 | |
61 /** | |
62 * Registers the methods in this class that should be listeners. | |
63 * | |
64 * @return array | |
65 * An array of event listener definitions. | |
66 */ | |
67 public static function getSubscribedEvents() { | |
68 $events[ConfigEvents::IMPORT][] = ['onConfigImporterImport', 40]; | |
69 return $events; | |
70 } | |
71 | |
72 } |