TwigVariableParser example

TWIG;

        $twig = new Environment(new ArrayLoader([]));
        $twig->addExtension(new DebugExtension());
        $parser = new TwigVariableParser($twig);

        $variables = $parser->parse($template);

        $expected = [
            'product.price.gross',
            'product.prices',
            'product.name',
            'product.stock',
            'product.translated.name',
            'product.manufacturer.cover.id',
            'product.media',
        ];
namespace Shopware\Core\Framework\Adapter\Twig;

use Shopware\Core\Framework\Log\Package;
use Twig\Environment;

#[Package('core')] class TwigVariableParserFactory
{
    public function getParser(Environment $twig): TwigVariableParser
    {
        return new TwigVariableParser($twig);
    }
}
Home | Imprint | This part of the site doesn't use cookies.