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

Breadcrumb

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

function PhpDumper::getExpressionLanguage

File

vendor/symfony/dependency-injection/Dumper/PhpDumper.php, line 2155

Class

PhpDumper
PhpDumper dumps a service container as a PHP class.

Namespace

Symfony\Component\DependencyInjection\Dumper

Code

private function getExpressionLanguage() : ExpressionLanguage {
    if (!isset($this->expressionLanguage)) {
        if (!class_exists(\Symfony\Component\ExpressionLanguage\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 ($arg) {
            $id = '""' === substr_replace($arg, '', 1, -1) ? stripcslashes(substr($arg, 1, -1)) : null;
            if (null !== $id && ($this->container
                ->hasAlias($id) || $this->container
                ->hasDefinition($id))) {
                return $this->getServiceCall($id);
            }
            return \sprintf('$container->get(%s)', $arg);
        });
        if ($this->container
            ->isTrackingResources()) {
            foreach ($providers as $provider) {
                $this->container
                    ->addObjectResource($provider);
            }
        }
    }
    return $this->expressionLanguage;
}
RSS feed
Powered by Drupal