Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ExpressionParser.php

function ExpressionParser::getFunction

1 call to ExpressionParser::getFunction()
ExpressionParser::getFunctionNode in vendor/twig/twig/src/ExpressionParser.php

File

vendor/twig/twig/src/ExpressionParser.php, line 803

Class

ExpressionParser
Parses expressions.

Namespace

Twig

Code

private function getFunction(string $name, int $line) : TwigFunction {
    if (!($function = $this->env
        ->getFunction($name))) {
        if ($this->parser
            ->shouldIgnoreUnknownTwigCallables()) {
            return new TwigFunction($name, fn() => '');
        }
        $e = new SyntaxError(\sprintf('Unknown "%s" function.', $name), $line, $this->parser
            ->getStream()
            ->getSourceContext());
        $e->addSuggestions($name, array_keys($this->env
            ->getFunctions()));
        throw $e;
    }
    if ($function->isDeprecated()) {
        $src = $this->parser
            ->getStream()
            ->getSourceContext();
        $function->triggerDeprecation($src->getPath() ?: $src->getName(), $line);
    }
    return $function;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal