Parcourir la source

use synthetic services instead of special exceptions

Lukas Kahwe Smith il y a 14 ans
Parent
commit
a4b04c4add

+ 4 - 0
src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml

@@ -47,6 +47,10 @@
         -->
         <service id="request" scope="request" synthetic="true" />
 
+        <service id="service_container" synthetic="true" />
+
+        <service id="kernel" synthetic="true" />
+
         <service id="filesystem" class="%filesystem.class%"></service>
 
         <service id="file_locator" class="%file_locator.class%">

+ 1 - 26
src/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php

@@ -24,27 +24,6 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
 class ResolveInvalidReferencesPass implements CompilerPassInterface
 {
     private $container;
-    private $exceptions;
-
-    /**
-     * Constructor.
-     *
-     * @param array $exceptions An array of exceptions
-     */
-    public function __construct(array $exceptions = array('kernel', 'service_container', 'templating.loader.wrapped', 'pdo_connection'))
-    {
-        $this->exceptions = $exceptions;
-    }
-
-    /**
-     * Add an exception.
-     *
-     * @param string $id Exception identifier
-     */
-    public function addException($id)
-    {
-        $this->exceptions[] = $id;
-    }
 
     /**
      * Process the ContainerBuilder to resolve invalid references.
@@ -100,10 +79,6 @@ class ResolveInvalidReferencesPass implements CompilerPassInterface
             } else if ($argument instanceof Reference) {
                 $id = (string) $argument;
 
-                if (in_array($id, $this->exceptions, true)) {
-                    continue;
-                }
-
                 $invalidBehavior = $argument->getInvalidBehavior();
                 $exists = $this->container->has($id);
 
@@ -124,4 +99,4 @@ class ResolveInvalidReferencesPass implements CompilerPassInterface
 
         return $arguments;
     }
-}
+}