app/AppKernel.php line 120

Open in your IDE?
  1. <?php
  2. use App\Backoffice\DependencyInjection\CompilerPass\ExporterPass;
  3. use App\Core\AppConfiguration\AppConfigurationInterface;
  4. use App\Core\Cron\DependencyInjection\CronPass;
  5. use App\Dev\DependencyInjection\AwsPass;
  6. use App\Dev\DependencyInjection\DevFilesystemPass;
  7. use App\Core\Job\DependencyInjection\JobCommandPass;
  8. use App\Core\Symfony\Environment;
  9. use DocumentBundle\Model\TableMergeField\TableMergeFieldInterface;
  10. use Symfony\Component\Config\Loader\LoaderInterface;
  11. use Symfony\Component\DependencyInjection\ContainerBuilder;
  12. use Symfony\Component\Dotenv\Dotenv;
  13. use Symfony\Component\HttpKernel\Kernel;
  14. use Symfony\Component\Routing\RouteCollectionBuilder;
  15. class AppKernel extends Kernel
  16. {
  17.     private const CONFIG_EXTS '.{php,xml,yaml,yml}';
  18.     public function registerBundles()
  19.     {
  20.         $bundles = [
  21.             new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
  22.             new Symfony\Bundle\SecurityBundle\SecurityBundle(),
  23.             new Symfony\Bundle\TwigBundle\TwigBundle(),
  24.             new Symfony\Bundle\MonologBundle\MonologBundle(),
  25.             new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
  26.             new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
  27.             new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
  28.             new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
  29.             new FOS\RestBundle\FOSRestBundle(),
  30.             new FOS\UserBundle\FOSUserBundle(),
  31.             new JMS\SerializerBundle\JMSSerializerBundle(),
  32.             new OldSound\RabbitMqBundle\OldSoundRabbitMqBundle(),
  33.             new Oneup\FlysystemBundle\OneupFlysystemBundle(),
  34.             new Snc\RedisBundle\SncRedisBundle(),
  35.             new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
  36.             new Bazinga\Bundle\JsTranslationBundle\BazingaJsTranslationBundle(),
  37.             new AppBundle\AppBundle(),
  38.             new CommonBundle\CommonBundle(),
  39.             new DocumentBundle\DocumentBundle(),
  40.             new DriveBundle\DriveBundle(),
  41.             new Craue\FormFlowBundle\CraueFormFlowBundle(),
  42.             new BillingBundle\BillingBundle(),
  43.             new Liip\ImagineBundle\LiipImagineBundle(),
  44.             new SettingsBundle\SettingsBundle(),
  45.             new CRMBundle\CRMBundle(),
  46.             new APY\DataGridBundle\APYDataGridBundle(),
  47.             new \Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
  48.             new CalendarBundle\CalendarBundle(),
  49.             new \FOS\ElasticaBundle\FOSElasticaBundle(),
  50.             new Sg\DatatablesBundle\SgDatatablesBundle(),
  51.             new \MigrationBundle\MigrationBundle(),
  52.             new Gos\Bundle\WebSocketBundle\GosWebSocketBundle(),
  53.             new Gos\Bundle\PubSubRouterBundle\GosPubSubRouterBundle(),
  54.             new Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle(),
  55.             new Gesdinet\JWTRefreshTokenBundle\GesdinetJWTRefreshTokenBundle(),
  56.             new Nelmio\CorsBundle\NelmioCorsBundle(),
  57.             new Sentry\SentryBundle\SentryBundle(),
  58.             new BabDev\PagerfantaBundle\BabDevPagerfantaBundle(),
  59.             new Scheb\TwoFactorBundle\SchebTwoFactorBundle(),
  60.             new KnpU\OAuth2ClientBundle\KnpUOAuth2ClientBundle(),
  61.         ];
  62.         if ($this->getEnvironment() === Environment::Dev->value) {
  63.             $bundles[] = new Nelmio\ApiDocBundle\NelmioApiDocBundle();
  64.         }
  65.         if (in_array($this->getEnvironment(), [Environment::Dev->valueEnvironment::AwsDev->valueEnvironment::Test->valueEnvironment::Phpunit->value], true)) {
  66.             $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
  67.             $bundles[] = new Symfony\Bundle\MakerBundle\MakerBundle();
  68.         }
  69.         if (in_array($this->getEnvironment(), [Environment::Test->valueEnvironment::Phpunit->value], true)) {
  70.             $bundles[] = new DAMA\DoctrineTestBundle\DAMADoctrineTestBundle();
  71.             $bundles[] = new Zenstruck\Foundry\ZenstruckFoundryBundle();
  72.         }
  73.         if (in_array($this->getEnvironment(), [Environment::Uat->valueEnvironment::Dev->valueEnvironment::AwsDev->valueEnvironment::AwsPreprod->valueEnvironment::Test->valueEnvironment::Phpunit->value], true)) {
  74.             $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
  75.             $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
  76.         }
  77.         return $bundles;
  78.     }
  79.     public function getRootDir()
  80.     {
  81.         return __DIR__;
  82.     }
  83.     public function getCacheDir()
  84.     {
  85.         return dirname(__DIR__) . '/var/cache/' $this->getEnvironment();
  86.     }
  87.     public function getLogDir()
  88.     {
  89.         return dirname(__DIR__) . '/var/logs';
  90.     }
  91.     public function registerContainerConfiguration(LoaderInterface $loader)
  92.     {
  93.         $confDir $this->getProjectDir().'/app/config';
  94.         $loader->load($confDir '/config_' $this->getEnvironment() . '.yml');
  95.         $loader->load($confDir '/app/*' self::CONFIG_EXTS'glob');
  96.         $loader->load($confDir '/packages/*' self::CONFIG_EXTS'glob');
  97.         if (is_dir($confDir '/packages/' $this->environment)) {
  98.             $loader->load($confDir '/packages/' $this->environment '/**/*' self::CONFIG_EXTS'glob');
  99.         }
  100.     }
  101.     /**
  102.      * @{inheritdoc}
  103.      */
  104.     public function boot()
  105.     {
  106.         // Using environment variables to set some config var
  107.         (new Dotenv(true))->load(__DIR__.'/../.env');
  108.         parent::boot();
  109.     }
  110.     /**
  111.      * @inheritDoc
  112.      */
  113.     protected function build(ContainerBuilder $container): void
  114.     {
  115.         $container->registerForAutoconfiguration(TableMergeFieldInterface::class)
  116.             ->addTag('app.table_merge_field');
  117.         $container->registerForAutoconfiguration(AppConfigurationInterface::class)
  118.             ->addTag('app.configuration');
  119.         $container->addCompilerPass(new ExporterPass());
  120.         $container->addCompilerPass(new CronPass());
  121.         $container->addCompilerPass(new JobCommandPass());
  122.         if ($this->getEnvironment() === Environment::Dev->value) {
  123.             $container->addCompilerPass(new AwsPass());
  124.             $container->addCompilerPass(new DevFilesystemPass());
  125.         }
  126.     }
  127. }