From d4092c23ae58009a6ae8957d55753886b70ed891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Mon, 11 Nov 2024 05:47:23 +0100 Subject: [PATCH] Add kernel reset --- src/TwigComponent/src/ComponentRenderer.php | 8 +++++++- .../src/DependencyInjection/TwigComponentExtension.php | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) 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)