vendor/shopware/core/Framework/Adapter/Twig/Extension/SeoUrlFunctionExtension.php line 37

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Adapter\Twig\Extension;
  3. use Shopware\Core\Content\Seo\SeoUrlPlaceholderHandlerInterface;
  4. use Symfony\Bridge\Twig\Extension\RoutingExtension;
  5. use Twig\Extension\AbstractExtension;
  6. use Twig\TwigFunction;
  7. class SeoUrlFunctionExtension extends AbstractExtension
  8. {
  9.     /**
  10.      * @var AbstractExtension
  11.      */
  12.     private $routingExtension;
  13.     /**
  14.      * @var SeoUrlPlaceholderHandlerInterface
  15.      */
  16.     private $seoUrlReplacer;
  17.     public function __construct(RoutingExtension $extensionSeoUrlPlaceholderHandlerInterface $seoUrlReplacer)
  18.     {
  19.         $this->routingExtension $extension;
  20.         $this->seoUrlReplacer $seoUrlReplacer;
  21.     }
  22.     public function getFunctions(): array
  23.     {
  24.         return [
  25.             new TwigFunction('seoUrl', [$this'seoUrl'], ['is_safe_callback' => [$this->routingExtension'isUrlGenerationSafe']]),
  26.         ];
  27.     }
  28.     public function seoUrl(string $name, array $parameters = []): string
  29.     {
  30.         return $this->seoUrlReplacer->generate($name$parameters);
  31.     }
  32. }