diff --git a/src/Icons/config/services.php b/src/Icons/config/services.php index 7d0dc0abd11..fa5e7e5606b 100644 --- a/src/Icons/config/services.php +++ b/src/Icons/config/services.php @@ -53,6 +53,7 @@ service('logger')->ignoreOnInvalid(), ]) ->tag('twig.runtime') + ->tag('ux.twig_component.twig_renderer', ['key' => 'ux:icon']) ->set('.ux_icons.icon_renderer', IconRenderer::class) ->args([ diff --git a/src/Map/config/services.php b/src/Map/config/services.php index c94a9043cd9..961eb365b46 100644 --- a/src/Map/config/services.php +++ b/src/Map/config/services.php @@ -47,5 +47,6 @@ service('ux_map.renderers'), ]) ->tag('twig.runtime') + ->tag('ux.twig_component.twig_renderer', ['key' => 'ux:map']) ; }; diff --git a/src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php b/src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php index aa1419ee88b..72cd6f261ab 100644 --- a/src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php +++ b/src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php @@ -17,6 +17,8 @@ use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Argument\AbstractArgument; +use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; +use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\LogicException; @@ -36,8 +38,6 @@ use Symfony\UX\TwigComponent\Twig\ComponentLexer; use Symfony\UX\TwigComponent\Twig\ComponentRuntime; use Symfony\UX\TwigComponent\Twig\TwigEnvironmentConfigurator; -use function Symfony\Component\DependencyInjection\Loader\Configurator\service; -use function Symfony\Component\DependencyInjection\Loader\Configurator\service_locator; /** * @author Kevin Bond @@ -110,10 +110,7 @@ class_exists(AbstractArgument::class) ? new AbstractArgument(\sprintf('Added in $container->register('.ux.twig_component.twig.component_runtime', ComponentRuntime::class) ->setArguments([ new Reference('ux.twig_component.component_renderer'), - service_locator([ - 'ux:icon' => service('.ux_icons.twig_icon_runtime')->nullOnInvalid(), - 'ux:map' => service('ux_map.twig_runtime')->nullOnInvalid(), - ]), + new ServiceLocatorArgument(new TaggedIteratorArgument('ux.twig_component.twig_renderer', indexAttribute: 'key', needsIndexes: true)), ]) ->addTag('twig.runtime') ;