Completed
Push — master ( 7c9eb0...a92430 )
by Thomas
13s
created

AbstractOverrideConfigAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 26
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 4 1
A process() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the ekino Drupal Debug project.
7
 *
8
 * (c) ekino
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Ekino\Drupal\Debug\Action;
15
16
use Ekino\Drupal\Debug\Kernel\Event\DebugKernelEvents;
17
use Symfony\Component\PropertyAccess\PropertyAccess;
18
19
abstract class AbstractOverrideConfigAction implements EventSubscriberActionInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24 1
    public static function getSubscribedEvents(): array
25
    {
26
        return array(
27 1
            DebugKernelEvents::AFTER_SETTINGS_INITIALIZATION => 'process',
28
        );
29
    }
30
31 3
    public function process(): void
32
    {
33 3
        global $config;
34
35 3
        $propertyAccessor = PropertyAccess::createPropertyAccessor();
36 3
        foreach ($this->getOverrides() as $propertyPath => $value) {
37 3
            $propertyAccessor->setValue($config, $propertyPath, $value);
38
        }
39 3
    }
40
41
    /**
42
     * @return array
43
     */
44
    abstract protected function getOverrides(): array;
45
}
46