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

Breadcrumb

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

function AbstractRecursivePass::getExpressionLanguage

1 method overrides AbstractRecursivePass::getExpressionLanguage()
CheckTypeDeclarationsPass::getExpressionLanguage in vendor/symfony/dependency-injection/Compiler/CheckTypeDeclarationsPass.php

File

vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php, line 231

Class

AbstractRecursivePass
@author Nicolas Grekas <p@tchwork.com>

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

private function getExpressionLanguage() : ExpressionLanguage {
    if (!isset($this->expressionLanguage)) {
        if (!class_exists(ExpressionLanguage::class)) {
            throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".');
        }
        $providers = $this->container
            ->getExpressionLanguageProviders();
        $this->expressionLanguage = new ExpressionLanguage(null, $providers, function (string $arg) : string {
            if ('""' === substr_replace($arg, '', 1, -1)) {
                $id = stripcslashes(substr($arg, 1, -1));
                $this->inExpression = true;
                $arg = $this->processValue(new Reference($id));
                $this->inExpression = false;
                if (!$arg instanceof Reference) {
                    throw new RuntimeException(\sprintf('"%s::processValue()" must return a Reference when processing an expression, "%s" returned for service("%s").', static::class, get_debug_type($arg), $id));
                }
                $arg = \sprintf('"%s"', $arg);
            }
            return \sprintf('$this->get(%s)', $arg);
        });
    }
    return $this->expressionLanguage;
}

API Navigation

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