public function __construct( private readonly Environment
$platformTwig,
private readonly string
$cacheDir ) { $this->
initialize();
} public function initialize(): void
{ // use private twig instance here, because we use custom template loader
$this->twig =
new TwigEnvironment(new ArrayLoader(),
[ 'cache' =>
new FilesystemCache($this->cacheDir . '/string-template-renderer'
),
]);
$this->
disableTestMode();
foreach ($this->platformTwig->
getExtensions() as $extension) { if ($this->twig->
hasExtension($extension::
class)) { continue;
} $this->twig->
addExtension($extension);
} if ($this->twig->
hasExtension(CoreExtension::
class) &&
$this->platformTwig->
hasExtension(CoreExtension::
class)) { /** @var CoreExtension $coreExtensionInternal */