4
4
5
5
use Drupal \Core \Config \ConfigCrudEvent ;
6
6
use Drupal \Core \Config \ConfigEvents ;
7
+ use Drupal \Core \Config \ConfigFactoryInterface ;
7
8
use Drupal \Core \Menu \LocalTaskManager ;
8
9
use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
9
10
@@ -24,14 +25,24 @@ final class ConfigSubscriber implements EventSubscriberInterface {
24
25
*/
25
26
private $ localTaskManager ;
26
27
28
+ /**
29
+ * The config factory.
30
+ *
31
+ * @var \Drupal\Core\Config\ConfigFactoryInterface
32
+ */
33
+ protected $ configFactory ;
34
+
27
35
/**
28
36
* ConfigSubscriber constructor.
29
37
*
30
38
* @param \Drupal\Core\Menu\LocalTaskManager $local_task_manager
31
39
* The local task plugin manager.
40
+ * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
41
+ * The config factory.
32
42
*/
33
- public function __construct (LocalTaskManager $ local_task_manager ) {
43
+ public function __construct (LocalTaskManager $ local_task_manager, ConfigFactoryInterface $ config_factory ) {
34
44
$ this ->localTaskManager = $ local_task_manager ;
45
+ $ this ->configFactory = $ config_factory ;
35
46
}
36
47
37
48
/**
@@ -74,9 +85,8 @@ public static function getSubscribedEvents(): array {
74
85
* @param array $configurations
75
86
* An array of drupal configurations.
76
87
*/
77
- function updatePageConfigurations (string $ config_name , array $ configurations ) {
78
- $ configFactory = \Drupal::service ('config.factory ' );
79
- $ config = $ configFactory ->getEditable ($ config_name );
88
+ public function updatePageConfigurations (string $ config_name , array $ configurations ) {
89
+ $ config = $ this ->configFactory ->getEditable ($ config_name );
80
90
$ need_save = FALSE ;
81
91
if ($ config ) {
82
92
foreach ($ configurations as $ key => $ value ) {
0 commit comments