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

getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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