From b16d463a6f5ea66ca4a5f770d48ea794e78e9235 Mon Sep 17 00:00:00 2001 From: Alexander Menk Date: Mon, 14 Sep 2026 20:20:42 +0200 Subject: [PATCH] Extend Shopware's TwigEnvironment in TwigDecorator CustomProfilerExtensions replaces the class of the `twig` service with TwigDecorator. Shopware sets that service's class to Shopware\Core\Framework\Adapter\Twig\TwigEnvironment, so extending plain Twig\Environment silently drops Shopware's own Twig behaviour -- `use_yield`, the CoreExtension and EscaperRuntime overrides in compile(), and ResetInterface. Since Shopware 6.7.14.0 it also breaks the shop. The new DocumentV2 subsystem type-hints the concrete TwigEnvironment: Shopware\Core\Checkout\DocumentV2\Template\DocumentTemplateRenderer::__construct(): Argument #2 ($twig) must be of type Shopware\Core\Framework\Adapter\Twig\TwigEnvironment, Frosh\DevelopmentHelper\Component\Profiler\TwigDecorator given GenerateDocumentAction now receives both DocumentGenerator and DocumentV2Generator, and FlowExecutor instantiates flow actions eagerly, so the renderer is constructed on any flow dispatch. A plain POST /api/customer answers 500 with the plugin installed, which takes down acceptance tests across the board. TwigEnvironment extends Twig\Environment, and it exists in both 6.6 and 6.7, so this stays within the plugin's `~6.6.0 || ~6.7.0` requirement. Co-Authored-By: Claude Opus 5 --- src/Component/Profiler/TwigDecorator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Component/Profiler/TwigDecorator.php b/src/Component/Profiler/TwigDecorator.php index 0adb21f..e9f59bf 100644 --- a/src/Component/Profiler/TwigDecorator.php +++ b/src/Component/Profiler/TwigDecorator.php @@ -2,10 +2,10 @@ namespace Frosh\DevelopmentHelper\Component\Profiler; -use Twig\Environment; +use Shopware\Core\Framework\Adapter\Twig\TwigEnvironment; use Twig\TemplateWrapper; -class TwigDecorator extends Environment +class TwigDecorator extends TwigEnvironment { private array $renders = [];