vendor/zenstruck/foundry/src/ZenstruckFoundryBundle.php line 26

  1. <?php
  2. /*
  3.  * This file is part of the zenstruck/foundry package.
  4.  *
  5.  * (c) Kevin Bond <kevinbond@gmail.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Zenstruck\Foundry;
  11. use Symfony\Component\DependencyInjection\ContainerBuilder;
  12. use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
  13. use Symfony\Component\HttpKernel\Bundle\Bundle;
  14. use Zenstruck\Foundry\Bundle\DependencyInjection\ChainManagerRegistryPass;
  15. use Zenstruck\Foundry\Bundle\DependencyInjection\GlobalStatePass;
  16. use Zenstruck\Foundry\Bundle\DependencyInjection\ZenstruckFoundryExtension;
  17. /**
  18.  * Must be at src root to be auto-configured by Symfony Flex.
  19.  *
  20.  * @author Kevin Bond <kevinbond@gmail.com>
  21.  */
  22. final class ZenstruckFoundryBundle extends Bundle
  23. {
  24.     public function boot(): void
  25.     {
  26.         if (!Factory::isBooted()) {
  27.             Factory::boot($this->container->get('.zenstruck_foundry.configuration'));
  28.         }
  29.     }
  30.     public function build(ContainerBuilder $container): void
  31.     {
  32.         parent::build($container);
  33.         $container->addCompilerPass(new ChainManagerRegistryPass());
  34.         $container->addCompilerPass(new GlobalStatePass());
  35.     }
  36.     protected function createContainerExtension(): ?ExtensionInterface
  37.     {
  38.         return new ZenstruckFoundryExtension();
  39.     }
  40. }