zend-blog-3-backend
66 строк · 2.2 Кб
1<?php
2
3namespace App;4
5use App\DependencyInjection\CronCompilerPass;6use App\DependencyInjection\Security\Factory\WsseFactory;7use App\DependencyInjection\TelegramCompilerPass;8use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;9use Symfony\Component\DependencyInjection\ContainerBuilder;10use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;11use Symfony\Component\HttpKernel\Kernel as BaseKernel;12use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;13
14class Kernel extends BaseKernel15{
16use MicroKernelTrait;17
18public function __construct(string $environment, bool $debug)19{20parent::__construct($environment, $debug);21
22if (!defined('APP_VAR_DIR')) {23define('APP_VAR_DIR', dirname(__DIR__, 2) . '/var');24}25if (!defined('APP_WEB_DIR')) {26define('APP_WEB_DIR', dirname(__DIR__, 2) . '/web');27}28}29
30public function getProjectDir(): string31{32return dirname(__DIR__, 2);33}34
35public function build(ContainerBuilder $container): void36{37$container->addCompilerPass(new CronCompilerPass());38$container->addCompilerPass(new TelegramCompilerPass());39
40$extension = $container->getExtension('security');41$extension->addSecurityListenerFactory(new WsseFactory());42}43
44protected function configureContainer(ContainerConfigurator $container): void45{46$confDir = $this->getProjectDir() . '/config';47
48$container->import($confDir . '/{packages}/*.yaml');49$container->import($confDir . '/{packages}/' . $this->environment . '/*.yaml');50if (is_file($confDir . '/services.yaml')) {51$container->import($confDir . '/services.yaml');52$container->import($confDir . '/{services}_' . $this->environment . '.yaml');53}54}55
56protected function configureRoutes(RoutingConfigurator $routes): void57{58$confDir = $this->getProjectDir() . '/config';59
60$routes->import($confDir . '/{routes}/' . $this->environment . '/*.yaml');61$routes->import($confDir . '/{routes}/*.yaml');62if (is_file($confDir . '/routes.yaml')) {63$routes->import($confDir . '/routes.yaml');64}65}66}
67