-
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathKernel.php
More file actions
54 lines (46 loc) · 2.04 KB
/
Kernel.php
File metadata and controls
54 lines (46 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace App;
use App\Infrastructure\Config\AppConfig;
use App\Infrastructure\Config\PlatformEnvironment;
use App\Infrastructure\DependencyInjection\AppExpressionLanguageProvider;
use App\Infrastructure\DependencyInjection\Mutex\AutowireWithMutexPass;
use App\Infrastructure\DependencyInjection\Mutex\WithMutex;
use App\Infrastructure\KeyValue\KeyValueStore;
use App\Infrastructure\Theme\Theme;
use App\Infrastructure\ValueObject\String\KernelProjectDir;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
class Kernel extends BaseKernel
{
use MicroKernelTrait;
#[\Override]
public function build(ContainerBuilder $container): void
{
parent::build($container);
$container->registerAttributeForAutoconfiguration(WithMutex::class, static function (ChildDefinition $definition, WithMutex $attribute): void {
$definition->addTag('app.mutex', [
'mutex' => sprintf('mutex.%s', $attribute->getLockName()->value),
]);
});
$container->addCompilerPass(new AutowireWithMutexPass());
$container->addExpressionLanguageProvider(new AppExpressionLanguageProvider());
}
#[\Override]
protected function initializeContainer(): void
{
parent::initializeContainer();
$keyValueStore = $this->getContainer()->get(KeyValueStore::class);
assert($keyValueStore instanceof KeyValueStore);
Theme::setKeyValueStore($keyValueStore);
$kernelProjectDir = $this->getContainer()->get(KernelProjectDir::class);
assert($kernelProjectDir instanceof KernelProjectDir);
$platformEnvironment = $this->getContainer()->get(PlatformEnvironment::class);
assert($platformEnvironment instanceof PlatformEnvironment);
AppConfig::init(
kernelProjectDir: $kernelProjectDir,
platformEnvironment: $platformEnvironment
);
}
}