vendor/symfony/ux-turbo/src/TurboBundle.php line 23

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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 Symfony\UX\Turbo;
  11. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  12. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  13. use Symfony\Component\DependencyInjection\ContainerBuilder;
  14. use Symfony\Component\HttpKernel\Bundle\Bundle;
  15. use Symfony\UX\Turbo\DependencyInjection\Compiler\RegisterMercureHubsPass;
  16. /**
  17. * @author Kévin Dunglas <kevin@dunglas.fr>
  18. */
  19. final class TurboBundle extends Bundle
  20. {
  21. public const STREAM_FORMAT = 'turbo_stream';
  22. public const STREAM_MEDIA_TYPE = 'text/vnd.turbo-stream.html';
  23. public function build(ContainerBuilder $container): void
  24. {
  25. parent::build($container);
  26. $container->addCompilerPass(new RegisterMercureHubsPass());
  27. $container->addCompilerPass(new class implements CompilerPassInterface {
  28. public function process(ContainerBuilder $container): void
  29. {
  30. if (!$container->hasDefinition('turbo.broadcaster.imux')) {
  31. return;
  32. }
  33. if (!$container->getDefinition('turbo.broadcaster.imux')->getArgument(0)->getValues()) {
  34. $container->removeDefinition('turbo.doctrine.event_listener');
  35. }
  36. }
  37. }, PassConfig::TYPE_BEFORE_REMOVING);
  38. }
  39. public function getPath(): string
  40. {
  41. return \dirname(__DIR__);
  42. }
  43. }