-
Notifications
You must be signed in to change notification settings - Fork 284
Expand file tree
/
Copy pathKernel.php
More file actions
107 lines (93 loc) · 3.12 KB
/
Kernel.php
File metadata and controls
107 lines (93 loc) · 3.12 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
*/
namespace Combodo\iTop\Portal;
use DeprecatedCallsLog;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use utils;
/**
* Class Kernel
*
* @package Combodo\iTop\Portal
* @since 2.7.0
*/
class Kernel extends BaseKernel
{
use MicroKernelTrait;
/** @var string CONFIG_EXTS */
const CONFIG_EXTS = '.{php,xml,yaml,yml}';
/**
* @return string
*/
public function getCacheDir(): string
{
$cacheDir = $_ENV['PORTAL_ID'].'-'.$this->environment;
return utils::GetCachePath()."/portals/$cacheDir";
}
/**
* @return string
*/
public function getLogDir(): string
{
$logDir = $_ENV['PORTAL_ID'] . '-' . $this->environment;
return utils::GetLogPath() . "/portals/$logDir";
}
/**
* @return \Generator|iterable|\Symfony\Component\HttpKernel\Bundle\BundleInterface[]
*/
public function registerBundles(): iterable
{
$contents = require $this->getProjectDir().'/config/bundles.php';
foreach ($contents as $class => $envs) {
if (isset($envs[$this->environment]) || isset($envs['all'])) {
yield new $class();
}
}
}
/**
* @param \Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $container
*
* @return void
*/
protected function configureContainer(ContainerConfigurator $container)
{
$confDir = '../config';
$container->import(new FileResource($this->getProjectDir().'/config/bundles.php'));
$container->parameters()->set('container.dumper.inline_class_loader', true);
$container->import($confDir.'/{packages}/*'.self::CONFIG_EXTS);
$container->import($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS);
$container->import($confDir.'/{services}'.self::CONFIG_EXTS);
$container->import($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS);
}
/**
* @param \Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator $routes
*
* @return void
*/
protected function configureRoutes(RoutingConfigurator $routes)
{
$confDir = '../config';
$routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS);
$routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS);
$routes->import($confDir.'/{routes}'.self::CONFIG_EXTS);
}
}