Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / dependency-injection / Compiler / AnalyzeServiceReferencesPass.php
index 681f8afdde744c612c9b89e408fad7b47a2aabcb..68b2a0217263cff3c8675eaa89e71ab1a3fcb26d 100644 (file)
 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 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface
     private $currentDefinition;
     private $repeatedPass;
     private $onlyConstructorArguments;
+    private $expressionLanguage;
 
     /**
      * @param bool $onlyConstructorArguments Sets this Service Reference pass to ignore method calls
@@ -69,9 +72,6 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface
             $this->currentDefinition = $definition;
 
             $this->processArguments($definition->getArguments());
-            if ($definition->getFactoryService(false)) {
-                $this->processArguments(array(new Reference($definition->getFactoryService(false))));
-            }
             if (is_array($definition->getFactory())) {
                 $this->processArguments($definition->getFactory());
             }
@@ -100,6 +100,8 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface
         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,
@@ -116,9 +118,6 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface
                 if (is_array($argument->getFactory())) {
                     $this->processArguments($argument->getFactory());
                 }
-                if ($argument->getFactoryService(false)) {
-                    $this->processArguments(array(new Reference($argument->getFactoryService(false))));
-                }
             }
         }
     }
@@ -149,4 +148,27 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface
 
         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;
+    }
 }