vendor/symfony/ux-turbo/TurboBundle.php line 24

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. /**
  16.  * @author Kévin Dunglas <kevin@dunglas.fr>
  17.  *
  18.  * @experimental
  19.  */
  20. final class TurboBundle extends Bundle
  21. {
  22.     public function build(ContainerBuilder $container): void
  23.     {
  24.         parent::build($container);
  25.         $container->addCompilerPass(new class() implements CompilerPassInterface {
  26.             public function process(ContainerBuilder $container): void
  27.             {
  28.                 if (!$container->hasDefinition('turbo.broadcaster.imux')) {
  29.                     return;
  30.                 }
  31.                 if (!$container->getDefinition('turbo.broadcaster.imux')->getArgument(0)->getValues()) {
  32.                     $container->removeDefinition('turbo.doctrine.event_listener');
  33.                 }
  34.             }
  35.         }, PassConfig::TYPE_BEFORE_REMOVING);
  36.     }
  37. }