vendor/sylius/resource-bundle/src/Bundle/SyliusResourceBundle.php line 33

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Sylius package.
  4. *
  5. * (c) Paweł Jędrzejewski
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. declare(strict_types=1);
  11. namespace Sylius\Bundle\ResourceBundle;
  12. use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\CsrfTokenManagerPass;
  13. use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\DoctrineContainerRepositoryFactoryPass;
  14. use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\DoctrineTargetEntitiesResolverPass;
  15. use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\Helper\TargetEntitiesResolver;
  16. use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\PagerfantaBridgePass;
  17. use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterFormBuilderPass;
  18. use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterFqcnControllersPass;
  19. use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterResourceRepositoryPass;
  20. use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterResourcesPass;
  21. use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterStateMachinePass;
  22. use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\TwigPass;
  23. use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\WinzouStateMachinePass;
  24. use Sylius\Bundle\ResourceBundle\DependencyInjection\PagerfantaExtension;
  25. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  26. use Symfony\Component\DependencyInjection\ContainerBuilder;
  27. use Symfony\Component\HttpKernel\Bundle\Bundle;
  28. final class SyliusResourceBundle extends Bundle
  29. {
  30. public const DRIVER_DOCTRINE_ORM = 'doctrine/orm';
  31. public const DRIVER_DOCTRINE_MONGODB_ODM = 'doctrine/mongodb-odm';
  32. public const DRIVER_DOCTRINE_PHPCR_ODM = 'doctrine/phpcr-odm';
  33. public function build(ContainerBuilder $container): void
  34. {
  35. parent::build($container);
  36. $container->addCompilerPass(new CsrfTokenManagerPass());
  37. $container->addCompilerPass(new DoctrineContainerRepositoryFactoryPass());
  38. $container->addCompilerPass(new DoctrineTargetEntitiesResolverPass(new TargetEntitiesResolver()), PassConfig::TYPE_BEFORE_OPTIMIZATION, 1);
  39. $container->addCompilerPass(new RegisterFormBuilderPass());
  40. $container->addCompilerPass(new RegisterFqcnControllersPass());
  41. $container->addCompilerPass(new RegisterResourceRepositoryPass());
  42. $container->addCompilerPass(new RegisterResourcesPass());
  43. $container->addCompilerPass(new RegisterStateMachinePass());
  44. $container->addCompilerPass(new TwigPass());
  45. $container->addCompilerPass(new WinzouStateMachinePass());
  46. $container->registerExtension(new PagerfantaExtension(true));
  47. $container->addCompilerPass(new PagerfantaBridgePass(true), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1); // Should run after all passes from BabDevPagerfantaBundle
  48. }
  49. /**
  50. * @return string[]
  51. */
  52. public static function getAvailableDrivers(): array
  53. {
  54. return [
  55. self::DRIVER_DOCTRINE_ORM,
  56. self::DRIVER_DOCTRINE_MONGODB_ODM,
  57. self::DRIVER_DOCTRINE_PHPCR_ODM,
  58. ];
  59. }
  60. }