diff --git a/src/TwigComponent/src/ComponentRenderer.php b/src/TwigComponent/src/ComponentRenderer.php index c66f6abe56..2595d646bb 100644 --- a/src/TwigComponent/src/ComponentRenderer.php +++ b/src/TwigComponent/src/ComponentRenderer.php @@ -12,6 +12,7 @@ namespace Symfony\UX\TwigComponent; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Symfony\Contracts\Service\ResetInterface; use Symfony\UX\TwigComponent\Event\PostRenderEvent; use Symfony\UX\TwigComponent\Event\PreCreateForRenderEvent; use Symfony\UX\TwigComponent\Event\PreRenderEvent; @@ -22,7 +23,7 @@ * * @internal */ -final class ComponentRenderer implements ComponentRendererInterface +final class ComponentRenderer implements ComponentRendererInterface, ResetInterface { private array $templateClasses = []; @@ -139,4 +140,9 @@ private function preRender(MountedComponent $mounted, array $context = []): PreR return $event; } + + public function reset(): void + { + $this->templateClasses = []; + } } diff --git a/src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php b/src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php index 19432f6305..ebe2bb1753 100644 --- a/src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php +++ b/src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php @@ -113,6 +113,7 @@ static function (ChildDefinition $definition, AsTwigComponent $attribute) { new Reference('ux.twig_component.component_properties'), new Reference('ux.twig_component.component_stack'), ]) + ->addTag('kernel.reset', ['method' => 'reset']) ; $container->register('ux.twig_component.twig.component_extension', ComponentExtension::class)