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

Open in your IDE?
  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\RegisterFakerProvidersPass;
  17. use Zenstruck\Foundry\Bundle\DependencyInjection\ZenstruckFoundryExtension;
  18. /**
  19. * Must be at src root to be autoconfigured by Symfony Flex.
  20. *
  21. * @author Kevin Bond <kevinbond@gmail.com>
  22. */
  23. final class ZenstruckFoundryBundle extends Bundle
  24. {
  25. public function boot(): void
  26. {
  27. if (!Factory::isBooted() && $this->container) {
  28. Factory::boot($this->container->get('.zenstruck_foundry.configuration'));
  29. }
  30. }
  31. public function build(ContainerBuilder $container): void
  32. {
  33. parent::build($container);
  34. $container->addCompilerPass(new ChainManagerRegistryPass());
  35. $container->addCompilerPass(new GlobalStatePass());
  36. $container->addCompilerPass(new RegisterFakerProvidersPass());
  37. }
  38. protected function createContainerExtension(): ?ExtensionInterface
  39. {
  40. return new ZenstruckFoundryExtension();
  41. }
  42. }