vendor/shopware/core/Framework/Adapter/Twig/Extension/SwSanitizeTwigFilter.php line 33

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Adapter\Twig\Extension;
  3. use Shopware\Core\Framework\Util\HtmlSanitizer;
  4. use Twig\Extension\AbstractExtension;
  5. use Twig\TwigFilter;
  6. /**
  7.  * @package core
  8.  */
  9. class SwSanitizeTwigFilter extends AbstractExtension
  10. {
  11.     private HtmlSanitizer $sanitizer;
  12.     /**
  13.      * @internal
  14.      */
  15.     public function __construct(HtmlSanitizer $sanitizer)
  16.     {
  17.         $this->sanitizer $sanitizer;
  18.     }
  19.     public function getFilters(): array
  20.     {
  21.         return [
  22.             new TwigFilter('sw_sanitize', [$this'sanitize'], ['is_safe' => ['html']]),
  23.         ];
  24.     }
  25.     public function sanitize(string $text, ?array $options = [], bool $override false): string
  26.     {
  27.         return $this->sanitizer->sanitize($text$options$override);
  28.     }
  29. }