diff vendor/symfony/dependency-injection/Compiler/AnalyzeServiceReferencesPass.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children 1fec387a4317
line wrap: on
line diff
--- a/vendor/symfony/dependency-injection/Compiler/AnalyzeServiceReferencesPass.php	Fri Feb 23 15:51:18 2018 +0000
+++ b/vendor/symfony/dependency-injection/Compiler/AnalyzeServiceReferencesPass.php	Fri Feb 23 15:52:07 2018 +0000
@@ -12,8 +12,10 @@
 namespace Symfony\Component\DependencyInjection\Compiler;
 
 use Symfony\Component\DependencyInjection\Definition;
+use Symfony\Component\DependencyInjection\ExpressionLanguage;
 use Symfony\Component\DependencyInjection\Reference;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\ExpressionLanguage\Expression;
 
 /**
  * Run this pass before passes that need to know more about the relation of
@@ -32,6 +34,7 @@
     private $currentDefinition;
     private $repeatedPass;
     private $onlyConstructorArguments;
+    private $expressionLanguage;
 
     /**
      * @param bool $onlyConstructorArguments Sets this Service Reference pass to ignore method calls
@@ -97,6 +100,8 @@
         foreach ($arguments as $argument) {
             if (is_array($argument)) {
                 $this->processArguments($argument);
+            } elseif ($argument instanceof Expression) {
+                $this->getExpressionLanguage()->compile((string) $argument, array('this' => 'container'));
             } elseif ($argument instanceof Reference) {
                 $this->graph->connect(
                     $this->currentId,
@@ -143,4 +148,27 @@
 
         return $id;
     }
+
+    private function getExpressionLanguage()
+    {
+        if (null === $this->expressionLanguage) {
+            $providers = $this->container->getExpressionLanguageProviders();
+            $this->expressionLanguage = new ExpressionLanguage(null, $providers, function ($arg) {
+                if ('""' === substr_replace($arg, '', 1, -1)) {
+                    $id = stripcslashes(substr($arg, 1, -1));
+
+                    $this->graph->connect(
+                        $this->currentId,
+                        $this->currentDefinition,
+                        $this->getDefinitionId($id),
+                        $this->getDefinition($id)
+                    );
+                }
+
+                return sprintf('$this->get(%s)', $arg);
+            });
+        }
+
+        return $this->expressionLanguage;
+    }
 }