use Twig\Extension\ExtensionInterface;
use Twig\Loader\ArrayLoader;
#[Package('buyers-experience')]
class SeoUrlTwigFactory{ /**
* @param ExtensionInterface[] $twigExtensions
*/
public function createTwigEnvironment(SlugifyInterface
$slugify, iterable
$twigExtensions =
[]): Environment
{ $twig =
new TwigEnvironment(new ArrayLoader());
$twig->
setCache(false
);
$twig->
enableStrictVariables();
$twig->
addExtension(new SlugifyExtension($slugify));
$twig->
addExtension(new PhpSyntaxExtension());
$twig->
addExtension(new SecurityExtension([]));
/** @var EscaperExtension $coreExtension */
$coreExtension =
$twig->
getExtension(EscaperExtension::
class);
$coreExtension->
setEscaper( SeoUrlGenerator::ESCAPE_SLUGIFY,
// Do not remove $_twig, although it is marked as unused. It somehow important