You are here

protected function Twig_ExpressionParser::getFilterNodeClass in Translation template extractor 6.3

Same name and namespace in other branches
  1. 7.3 vendor/Twig/ExpressionParser.php \Twig_ExpressionParser::getFilterNodeClass()
2 calls to Twig_ExpressionParser::getFilterNodeClass()
Twig_ExpressionParser::parseFilterExpressionRaw in vendor/Twig/ExpressionParser.php
Twig_ExpressionParser::parseSubscriptExpression in vendor/Twig/ExpressionParser.php

File

vendor/Twig/ExpressionParser.php, line 563

Class

Twig_ExpressionParser
Parses expressions.

Code

protected function getFilterNodeClass($name, $line) {
  $env = $this->parser
    ->getEnvironment();
  if (false === ($filter = $env
    ->getFilter($name))) {
    $message = sprintf('The filter "%s" does not exist', $name);
    if ($alternatives = $env
      ->computeAlternatives($name, array_keys($env
      ->getFilters()))) {
      $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
    }
    throw new Twig_Error_Syntax($message, $line, $this->parser
      ->getFilename());
  }
  if ($filter instanceof Twig_SimpleFilter) {
    return $filter
      ->getNodeClass();
  }
  return $filter instanceof Twig_Filter_Node ? $filter
    ->getClass() : 'Twig_Node_Expression_Filter';
}