-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKernel.php
More file actions
67 lines (53 loc) · 2.23 KB
/
Copy pathKernel.php
File metadata and controls
67 lines (53 loc) · 2.23 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
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
declare(strict_types=1);
namespace CodedMonkey\Dirigent;
use CodedMonkey\Dirigent\DependencyInjection\Compiler\EncryptionPass;
use CodedMonkey\Dirigent\DependencyInjection\Compiler\ParametersPass;
use CodedMonkey\Dirigent\DependencyInjection\DirigentExtension;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
class Kernel extends BaseKernel
{
use MicroKernelTrait;
public const VERSION = '0.8.x-dev';
protected function configureContainer(ContainerConfigurator $container): void
{
$configDir = $this->getConfigDir();
$container->import($configDir . '/packages/*.yaml');
$container->import($configDir . '/services.yaml');
$container->import($configDir . '/dirigent.{json,php,yml,yaml}');
if (isset($_SERVER['DIRIGENT_IMAGE'])) {
$container->import('/srv/config/*.{json,php,yml,yaml}');
}
}
protected function build(ContainerBuilder $container): void
{
$container->registerExtension(new DirigentExtension());
$container->addCompilerPass(new EncryptionPass(), priority: 2048); // The encryption pass has to be the first pass to run as it removes sensitive data from the container
$container->addCompilerPass(new ParametersPass());
}
#[\Override]
public function boot(): void
{
parent::boot();
// Set Composer env vars
$_SERVER['COMPOSER_CACHE_DIR'] = $this->container->getParameter('dirigent.storage.path') . '/composer-cache';
$_SERVER['COMPOSER_HOME'] = $this->container->getParameter('dirigent.storage.path') . '/composer';
}
#[\Override]
public function getCacheDir(): string
{
return sprintf('%s/var/cache/symfony/%s', $this->getProjectDir(), $this->environment);
}
/**
* @return list<string> An array of allowed values for APP_ENV
*
* @phpstan-ignore method.unused (Method is called from KernelTrait which is not analyzed by PHPStan)
*/
private function getAllowedEnvs(): array
{
return ['prod', 'dev', 'test'];
}
}