vendor/contao/core-bundle/src/ContaoCoreBundle.php line 110

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of Contao.
  5.  *
  6.  * (c) Leo Feyer
  7.  *
  8.  * @license LGPL-3.0-or-later
  9.  */
  10. namespace Contao\CoreBundle;
  11. use Contao\CoreBundle\DependencyInjection\Compiler\AddAssetsPackagesPass;
  12. use Contao\CoreBundle\DependencyInjection\Compiler\AddAvailableTransportsPass;
  13. use Contao\CoreBundle\DependencyInjection\Compiler\AddCronJobsPass;
  14. use Contao\CoreBundle\DependencyInjection\Compiler\AddNativeTransportFactoryPass;
  15. use Contao\CoreBundle\DependencyInjection\Compiler\AddPackagesPass;
  16. use Contao\CoreBundle\DependencyInjection\Compiler\AddResourcesPathsPass;
  17. use Contao\CoreBundle\DependencyInjection\Compiler\AddSessionBagsPass;
  18. use Contao\CoreBundle\DependencyInjection\Compiler\CrawlerPass;
  19. use Contao\CoreBundle\DependencyInjection\Compiler\DataContainerCallbackPass;
  20. use Contao\CoreBundle\DependencyInjection\Compiler\IntlInstalledLocalesAndCountriesPass;
  21. use Contao\CoreBundle\DependencyInjection\Compiler\MakeServicesPublicPass;
  22. use Contao\CoreBundle\DependencyInjection\Compiler\PickerProviderPass;
  23. use Contao\CoreBundle\DependencyInjection\Compiler\RegisterFragmentsPass;
  24. use Contao\CoreBundle\DependencyInjection\Compiler\RegisterHookListenersPass;
  25. use Contao\CoreBundle\DependencyInjection\Compiler\RegisterPagesPass;
  26. use Contao\CoreBundle\DependencyInjection\Compiler\RemembermeServicesPass;
  27. use Contao\CoreBundle\DependencyInjection\Compiler\RewireTwigPathsPass;
  28. use Contao\CoreBundle\DependencyInjection\Compiler\SearchIndexerPass;
  29. use Contao\CoreBundle\DependencyInjection\Compiler\TaggedMigrationsPass;
  30. use Contao\CoreBundle\DependencyInjection\Compiler\TranslationDataCollectorPass;
  31. use Contao\CoreBundle\DependencyInjection\ContaoCoreExtension;
  32. use Contao\CoreBundle\DependencyInjection\Security\ContaoLoginFactory;
  33. use Contao\CoreBundle\Event\ContaoCoreEvents;
  34. use Contao\CoreBundle\Event\GenerateSymlinksEvent;
  35. use Contao\CoreBundle\Event\MenuEvent;
  36. use Contao\CoreBundle\Event\PreviewUrlConvertEvent;
  37. use Contao\CoreBundle\Event\PreviewUrlCreateEvent;
  38. use Contao\CoreBundle\Event\RobotsTxtEvent;
  39. use Contao\CoreBundle\Event\SlugValidCharactersEvent;
  40. use Contao\CoreBundle\Fragment\Reference\ContentElementReference;
  41. use Contao\CoreBundle\Fragment\Reference\FrontendModuleReference;
  42. use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
  43. use Symfony\Cmf\Component\Routing\DependencyInjection\Compiler\RegisterRouteEnhancersPass;
  44. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  45. use Symfony\Component\DependencyInjection\ContainerBuilder;
  46. use Symfony\Component\EventDispatcher\DependencyInjection\AddEventAliasesPass;
  47. use Symfony\Component\HttpKernel\Bundle\Bundle;
  48. use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass;
  49. class ContaoCoreBundle extends Bundle
  50. {
  51.     public const SCOPE_BACKEND 'backend';
  52.     public const SCOPE_FRONTEND 'frontend';
  53.     public function getContainerExtension(): ContaoCoreExtension
  54.     {
  55.         return new ContaoCoreExtension();
  56.     }
  57.     public function build(ContainerBuilder $container): void
  58.     {
  59.         parent::build($container);
  60.         /** @var SecurityExtension $extension */
  61.         $extension $container->getExtension('security');
  62.         $extension->addSecurityListenerFactory(new ContaoLoginFactory());
  63.         $container->addCompilerPass(
  64.             new AddEventAliasesPass([
  65.                 GenerateSymlinksEvent::class => ContaoCoreEvents::GENERATE_SYMLINKS,
  66.                 MenuEvent::class => ContaoCoreEvents::BACKEND_MENU_BUILD,
  67.                 PreviewUrlCreateEvent::class => ContaoCoreEvents::PREVIEW_URL_CREATE,
  68.                 PreviewUrlConvertEvent::class => ContaoCoreEvents::PREVIEW_URL_CONVERT,
  69.                 RobotsTxtEvent::class => ContaoCoreEvents::ROBOTS_TXT,
  70.                 SlugValidCharactersEvent::class => ContaoCoreEvents::SLUG_VALID_CHARACTERS,
  71.             ])
  72.         );
  73.         $container->addCompilerPass(new MakeServicesPublicPass());
  74.         $container->addCompilerPass(new AddPackagesPass());
  75.         $container->addCompilerPass(new AddAssetsPackagesPass());
  76.         $container->addCompilerPass(new AddSessionBagsPass());
  77.         $container->addCompilerPass(new AddResourcesPathsPass());
  78.         $container->addCompilerPass(new TaggedMigrationsPass());
  79.         $container->addCompilerPass(new PickerProviderPass());
  80.         $container->addCompilerPass(new RegisterPagesPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION1);
  81.         $container->addCompilerPass(
  82.             new RegisterFragmentsPass(
  83.                 FrontendModuleReference::TAG_NAME,
  84.                 FrontendModuleReference::GLOBALS_KEY,
  85.                 FrontendModuleReference::PROXY_CLASS,
  86.                 'contao.listener.module_template_options'
  87.             )
  88.         );
  89.         $container->addCompilerPass(
  90.             new RegisterFragmentsPass(
  91.                 ContentElementReference::TAG_NAME,
  92.                 ContentElementReference::GLOBALS_KEY,
  93.                 ContentElementReference::PROXY_CLASS,
  94.                 'contao.listener.element_template_options'
  95.             )
  96.         );
  97.         $container->addCompilerPass(new FragmentRendererPass('contao.fragment.handler'));
  98.         $container->addCompilerPass(new RemembermeServicesPass('contao_frontend'));
  99.         $container->addCompilerPass(new DataContainerCallbackPass());
  100.         $container->addCompilerPass(new TranslationDataCollectorPass());
  101.         $container->addCompilerPass(new RegisterHookListenersPass(), PassConfig::TYPE_OPTIMIZE);
  102.         $container->addCompilerPass(new SearchIndexerPass()); // Must be before the CrawlerPass
  103.         $container->addCompilerPass(new CrawlerPass());
  104.         $container->addCompilerPass(new AddCronJobsPass());
  105.         $container->addCompilerPass(new AddAvailableTransportsPass());
  106.         $container->addCompilerPass(new RegisterRouteEnhancersPass('contao.routing.page_router''contao.page_router_enhancer'));
  107.         $container->addCompilerPass(new RewireTwigPathsPass());
  108.         $container->addCompilerPass(new AddNativeTransportFactoryPass());
  109.         $container->addCompilerPass(new IntlInstalledLocalesAndCountriesPass());
  110.     }
  111. }