core/lib/Thelia/Core/Bundle/TheliaBundle.php line 45

  1. <?php
  2. /*
  3.  * This file is part of the Thelia package.
  4.  * http://www.thelia.net
  5.  *
  6.  * (c) OpenStudio <info@thelia.net>
  7.  *
  8.  * For the full copyright and license information, please view the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace Thelia\Core\Bundle;
  12. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  13. use Symfony\Component\DependencyInjection\ContainerBuilder;
  14. use Symfony\Component\HttpKernel\Bundle\Bundle;
  15. use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass;
  16. use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass;
  17. use Thelia\Core\DependencyInjection\Compiler\CurrencyConverterProviderPass;
  18. use Thelia\Core\DependencyInjection\Compiler\FallbackParserPass;
  19. use Thelia\Core\DependencyInjection\Compiler\RegisterArchiverPass;
  20. use Thelia\Core\DependencyInjection\Compiler\RegisterAssetFilterPass;
  21. use Thelia\Core\DependencyInjection\Compiler\RegisterCommandPass;
  22. use Thelia\Core\DependencyInjection\Compiler\RegisterCouponConditionPass;
  23. use Thelia\Core\DependencyInjection\Compiler\RegisterCouponPass;
  24. use Thelia\Core\DependencyInjection\Compiler\RegisterFormExtensionPass;
  25. use Thelia\Core\DependencyInjection\Compiler\RegisterFormPass;
  26. use Thelia\Core\DependencyInjection\Compiler\RegisterHookListenersPass;
  27. use Thelia\Core\DependencyInjection\Compiler\RegisterLoopPass;
  28. use Thelia\Core\DependencyInjection\Compiler\RegisterRouterPass;
  29. use Thelia\Core\DependencyInjection\Compiler\RegisterSerializerPass;
  30. use Thelia\Core\DependencyInjection\Compiler\TranslatorPass;
  31. use Thelia\Core\Service\ConfigCacheService;
  32. /**
  33.  * First Bundle use in Thelia
  34.  * It initialize dependency injection container.
  35.  *
  36.  * @TODO load configuration from thelia plugin
  37.  * @TODO register database configuration.
  38.  *
  39.  * @author Manuel Raynaud <manu@raynaud.io>
  40.  */
  41. class TheliaBundle extends Bundle
  42. {
  43.     /**
  44.      * Construct the depency injection builder.
  45.      */
  46.     public function build(ContainerBuilder $container): void
  47.     {
  48.         parent::build($container);
  49.         $container
  50.             ->addCompilerPass(new FallbackParserPass())
  51.             ->addCompilerPass(new TranslatorPass())
  52.             ->addCompilerPass(new ControllerArgumentValueResolverPass())
  53.             ->addCompilerPass(new RegisterControllerArgumentLocatorsPass())
  54.             ->addCompilerPass(new RegisterHookListenersPass(), PassConfig::TYPE_AFTER_REMOVING)
  55.             ->addCompilerPass(new RegisterRouterPass())
  56.             ->addCompilerPass(new RegisterCouponPass())
  57.             ->addCompilerPass(new RegisterCouponConditionPass())
  58.             ->addCompilerPass(new RegisterArchiverPass())
  59.             ->addCompilerPass(new RegisterAssetFilterPass())
  60.             ->addCompilerPass(new RegisterSerializerPass())
  61.             ->addCompilerPass(new RegisterFormExtensionPass())
  62.             ->addCompilerPass(new CurrencyConverterProviderPass())
  63.             ->addCompilerPass(new RegisterLoopPass())
  64.             ->addCompilerPass(new RegisterCommandPass())
  65.             ->addCompilerPass(new RegisterFormPass())
  66.         ;
  67.     }
  68.     public function boot(): void
  69.     {
  70.         /** @var ConfigCacheService $configCacheService */
  71.         $configCacheService $this->container->get(ConfigCacheService::class);
  72.         $configCacheService->initCacheConfigs();
  73.     }
  74. }