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

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\AddCronJobsPass;
  13. use Contao\CoreBundle\DependencyInjection\Compiler\AddPackagesPass;
  14. use Contao\CoreBundle\DependencyInjection\Compiler\AddResourcesPathsPass;
  15. use Contao\CoreBundle\DependencyInjection\Compiler\AddSessionBagsPass;
  16. use Contao\CoreBundle\DependencyInjection\Compiler\CrawlerPass;
  17. use Contao\CoreBundle\DependencyInjection\Compiler\DataContainerCallbackPass;
  18. use Contao\CoreBundle\DependencyInjection\Compiler\MakeServicesPublicPass;
  19. use Contao\CoreBundle\DependencyInjection\Compiler\PickerProviderPass;
  20. use Contao\CoreBundle\DependencyInjection\Compiler\RegisterFragmentsPass;
  21. use Contao\CoreBundle\DependencyInjection\Compiler\RegisterHookListenersPass;
  22. use Contao\CoreBundle\DependencyInjection\Compiler\RemembermeServicesPass;
  23. use Contao\CoreBundle\DependencyInjection\Compiler\SearchIndexerPass;
  24. use Contao\CoreBundle\DependencyInjection\Compiler\TaggedMigrationsPass;
  25. use Contao\CoreBundle\DependencyInjection\Compiler\TranslationDataCollectorPass;
  26. use Contao\CoreBundle\DependencyInjection\ContaoCoreExtension;
  27. use Contao\CoreBundle\DependencyInjection\Security\ContaoLoginFactory;
  28. use Contao\CoreBundle\Event\ContaoCoreEvents;
  29. use Contao\CoreBundle\Event\GenerateSymlinksEvent;
  30. use Contao\CoreBundle\Event\MenuEvent;
  31. use Contao\CoreBundle\Event\PreviewUrlConvertEvent;
  32. use Contao\CoreBundle\Event\PreviewUrlCreateEvent;
  33. use Contao\CoreBundle\Event\RobotsTxtEvent;
  34. use Contao\CoreBundle\Event\SlugValidCharactersEvent;
  35. use Contao\CoreBundle\Fragment\Reference\ContentElementReference;
  36. use Contao\CoreBundle\Fragment\Reference\FrontendModuleReference;
  37. use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
  38. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  39. use Symfony\Component\DependencyInjection\ContainerBuilder;
  40. use Symfony\Component\EventDispatcher\DependencyInjection\AddEventAliasesPass;
  41. use Symfony\Component\HttpKernel\Bundle\Bundle;
  42. use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass;
  43. class ContaoCoreBundle extends Bundle
  44. {
  45.     public const SCOPE_BACKEND 'backend';
  46.     public const SCOPE_FRONTEND 'frontend';
  47.     public function getContainerExtension(): ContaoCoreExtension
  48.     {
  49.         return new ContaoCoreExtension();
  50.     }
  51.     public function build(ContainerBuilder $container): void
  52.     {
  53.         parent::build($container);
  54.         /** @var SecurityExtension $extension */
  55.         $extension $container->getExtension('security');
  56.         $extension->addSecurityListenerFactory(new ContaoLoginFactory());
  57.         $container->addCompilerPass(
  58.             new AddEventAliasesPass([
  59.                 GenerateSymlinksEvent::class => ContaoCoreEvents::GENERATE_SYMLINKS,
  60.                 MenuEvent::class => ContaoCoreEvents::BACKEND_MENU_BUILD,
  61.                 PreviewUrlCreateEvent::class => ContaoCoreEvents::PREVIEW_URL_CREATE,
  62.                 PreviewUrlConvertEvent::class => ContaoCoreEvents::PREVIEW_URL_CONVERT,
  63.                 RobotsTxtEvent::class => ContaoCoreEvents::ROBOTS_TXT,
  64.                 SlugValidCharactersEvent::class => ContaoCoreEvents::SLUG_VALID_CHARACTERS,
  65.             ])
  66.         );
  67.         $container->addCompilerPass(new MakeServicesPublicPass());
  68.         $container->addCompilerPass(new AddPackagesPass());
  69.         $container->addCompilerPass(new AddAssetsPackagesPass());
  70.         $container->addCompilerPass(new AddSessionBagsPass());
  71.         $container->addCompilerPass(new AddResourcesPathsPass());
  72.         $container->addCompilerPass(new TaggedMigrationsPass());
  73.         $container->addCompilerPass(new PickerProviderPass());
  74.         $container->addCompilerPass(
  75.             new RegisterFragmentsPass(
  76.                 FrontendModuleReference::TAG_NAME,
  77.                 FrontendModuleReference::GLOBALS_KEY,
  78.                 FrontendModuleReference::PROXY_CLASS,
  79.                 'contao.listener.module_template_options'
  80.             )
  81.         );
  82.         $container->addCompilerPass(
  83.             new RegisterFragmentsPass(
  84.                 ContentElementReference::TAG_NAME,
  85.                 ContentElementReference::GLOBALS_KEY,
  86.                 ContentElementReference::PROXY_CLASS,
  87.                 'contao.listener.element_template_options'
  88.             )
  89.         );
  90.         $container->addCompilerPass(new FragmentRendererPass('contao.fragment.handler'));
  91.         $container->addCompilerPass(new RemembermeServicesPass('contao_frontend'));
  92.         $container->addCompilerPass(new DataContainerCallbackPass());
  93.         $container->addCompilerPass(new TranslationDataCollectorPass());
  94.         $container->addCompilerPass(new RegisterHookListenersPass(), PassConfig::TYPE_OPTIMIZE);
  95.         $container->addCompilerPass(new SearchIndexerPass()); // Must be before the CrawlerPass
  96.         $container->addCompilerPass(new CrawlerPass());
  97.         $container->addCompilerPass(new AddCronJobsPass());
  98.     }
  99. }