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\WatchContainerDefinitions; |
15
|
|
|
|
16
|
|
|
use Ekino\Drupal\Debug\Action\ActionWithOptionsInterface; |
17
|
|
|
use Ekino\Drupal\Debug\Action\EventSubscriberActionInterface; |
18
|
|
|
use Ekino\Drupal\Debug\Cache\FileBackend; |
19
|
|
|
use Ekino\Drupal\Debug\Cache\FileCache; |
20
|
|
|
use Ekino\Drupal\Debug\Helper\SettingsHelper; |
21
|
|
|
use Ekino\Drupal\Debug\Kernel\Event\AfterSettingsInitializationEvent; |
22
|
|
|
use Ekino\Drupal\Debug\Kernel\Event\DebugKernelEvents; |
23
|
|
|
|
24
|
|
|
class WatchContainerDefinitionsAction implements EventSubscriberActionInterface, ActionWithOptionsInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var WatchContainerDefinitionsOptions |
28
|
|
|
*/ |
29
|
|
|
private $options; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* {@inheritdoc} |
33
|
|
|
*/ |
34
|
1 |
|
public static function getSubscribedEvents(): array |
35
|
|
|
{ |
36
|
|
|
return array( |
37
|
1 |
|
DebugKernelEvents::AFTER_SETTINGS_INITIALIZATION => 'process', |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param WatchContainerDefinitionsOptions $options |
43
|
|
|
*/ |
44
|
3 |
|
public function __construct(WatchContainerDefinitionsOptions $options) |
45
|
|
|
{ |
46
|
3 |
|
$this->options = $options; |
47
|
3 |
|
} |
48
|
|
|
|
49
|
1 |
|
public function process(AfterSettingsInitializationEvent $event): void |
50
|
|
|
{ |
51
|
1 |
|
(new SettingsHelper())->override('[bootstrap_container_definition]', array( |
52
|
1 |
|
'services' => array( |
53
|
|
|
'cache.container' => array( |
54
|
|
|
'class' => FileBackend::class, |
55
|
|
|
'arguments' => array( |
56
|
1 |
|
new FileCache($this->options->getCacheFilePath(), $this->options->getFilteredResourcesCollection($event->getEnabledModules(), $event->getEnabledThemes())), |
57
|
|
|
), |
58
|
|
|
), |
59
|
|
|
), |
60
|
|
|
)); |
61
|
1 |
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritdoc} |
65
|
|
|
*/ |
66
|
3 |
|
public static function getOptionsClass(): string |
67
|
|
|
{ |
68
|
3 |
|
return WatchContainerDefinitionsOptions::class; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|