You are here

public function TwigExtension::getFilters in Twig Tweak 8

Same name and namespace in other branches
  1. 8.2 src/TwigExtension.php \Drupal\twig_tweak\TwigExtension::getFilters()

File

src/TwigExtension.php, line 49

Class

TwigExtension
Twig extension with some useful functions and filters.

Namespace

Drupal\twig_tweak

Code

public function getFilters() {
  $filters = [
    new \Twig_SimpleFilter('token_replace', [
      $this,
      'tokenReplaceFilter',
    ]),
    new \Twig_SimpleFilter('preg_replace', [
      $this,
      'pregReplaceFilter',
    ]),
    new \Twig_SimpleFilter('image_style', [
      $this,
      'imageStyle',
    ]),
    new \Twig_SimpleFilter('transliterate', [
      $this,
      'transliterate',
    ]),
    new \Twig_SimpleFilter('check_markup', [
      $this,
      'checkMarkup',
    ]),
  ];

  // PHP filter should be enabled in settings.php file.
  if (Settings::get('twig_tweak_enable_php_filter')) {
    $filters[] = new \Twig_SimpleFilter('php', [
      $this,
      'phpFilter',
    ]);
  }
  return $filters;
}