Forráskód Böngészése

added a FileLocator to DIC so that we can load resources like @BundleName/Resources/...

Fabien Potencier 14 éve
szülő
commit
e58a84eb09
39 módosított fájl, 343 hozzáadás és 202 törlés
  1. 0 1
      src/Symfony/Bundle/DoctrineAbstractBundle/DependencyInjection/AbstractDoctrineExtension.php
  2. 3 2
      src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php
  3. 3 2
      src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
  4. 2 1
      src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/XmlDoctrineExtensionTest.php
  5. 2 1
      src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/YamlDoctrineExtensionTest.php
  6. 2 1
      src/Symfony/Bundle/DoctrineMongoDBBundle/DependencyInjection/DoctrineMongoDBExtension.php
  7. 0 2
      src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/AbstractMongoDBExtensionTest.php
  8. 2 1
      src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/XmlMongoDBExtensionTest.php
  9. 2 1
      src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/YamlMongoDBExtensionTest.php
  10. 2 1
      src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
  11. 2 1
      src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php
  12. 2 1
      src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php
  13. 2 1
      src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/YamlFrameworkExtensionTest.php
  14. 4 3
      src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
  15. 2 1
      src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/PhpSecurityExtensionTest.php
  16. 2 1
      src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlSecurityExtensionTest.php
  17. 2 1
      src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/YamlSecurityExtensionTest.php
  18. 2 1
      src/Symfony/Bundle/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php
  19. 2 1
      src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php
  20. 3 2
      src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php
  21. 2 1
      src/Symfony/Bundle/ZendBundle/DependencyInjection/ZendExtension.php
  22. 9 62
      src/Symfony/Component/DependencyInjection/Loader/FileLoader.php
  23. 101 0
      src/Symfony/Component/DependencyInjection/Loader/FileLocator.php
  24. 1 1
      src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php
  25. 1 1
      src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php
  26. 1 1
      src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
  27. 1 1
      src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
  28. 50 0
      src/Symfony/Component/HttpKernel/DependencyInjection/Loader/FileLocator.php
  29. 7 6
      src/Symfony/Component/HttpKernel/Kernel.php
  30. 17 13
      src/Symfony/Component/HttpKernel/bootstrap.php
  31. 67 21
      src/Symfony/Component/HttpKernel/bootstrap_cache.php
  32. 3 2
      tests/Symfony/Tests/Component/DependencyInjection/CrossCheckTest.php
  33. 2 1
      tests/Symfony/Tests/Component/DependencyInjection/Loader/DelegatingLoaderTest.php
  34. 5 36
      tests/Symfony/Tests/Component/DependencyInjection/Loader/FileLoaderTest.php
  35. 3 2
      tests/Symfony/Tests/Component/DependencyInjection/Loader/IniFileLoaderTest.php
  36. 2 1
      tests/Symfony/Tests/Component/DependencyInjection/Loader/LoaderTest.php
  37. 3 2
      tests/Symfony/Tests/Component/DependencyInjection/Loader/PhpFileLoaderTest.php
  38. 16 15
      tests/Symfony/Tests/Component/DependencyInjection/Loader/XmlFileLoaderTest.php
  39. 11 10
      tests/Symfony/Tests/Component/DependencyInjection/Loader/YamlFileLoaderTest.php

+ 0 - 1
src/Symfony/Bundle/DoctrineAbstractBundle/DependencyInjection/AbstractDoctrineExtension.php

@@ -12,7 +12,6 @@
 namespace Symfony\Bundle\DoctrineAbstractBundle\DependencyInjection;
 
 use Symfony\Component\HttpKernel\DependencyInjection\Extension;
-use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Definition;
 use Symfony\Component\DependencyInjection\Reference;

+ 3 - 2
src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php

@@ -14,6 +14,7 @@ namespace Symfony\Bundle\DoctrineBundle\DependencyInjection;
 use Symfony\Component\DependencyInjection\Alias;
 use Symfony\Component\HttpKernel\DependencyInjection\Extension;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Definition;
 use Symfony\Component\DependencyInjection\Reference;
@@ -41,7 +42,7 @@ class DoctrineExtension extends AbstractDoctrineExtension
      */
     public function dbalLoad(array $configs, ContainerBuilder $container)
     {
-        $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
+        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
         $loader->load('dbal.xml');
 
         $config = $this->mergeDbalConfig($configs, $container);
@@ -231,7 +232,7 @@ class DoctrineExtension extends AbstractDoctrineExtension
      */
     public function ormLoad(array $configs, ContainerBuilder $container)
     {
-        $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
+        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
         $loader->load('orm.xml');
 
         $config = $this->mergeOrmConfig($configs, $container);

+ 3 - 2
src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php

@@ -18,6 +18,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
 use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 abstract class AbstractDoctrineExtensionTest extends TestCase
 {
@@ -59,7 +60,7 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
         $loader = new DoctrineExtension();
         $container->registerExtension($loader);
 
-        $loadXml = new XmlFileLoader($container, __DIR__.'/Fixtures/config/xml');
+        $loadXml = new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/config/xml'));
         $loadXml->load('dbal_service_multiple_connections.xml');
         $loader->dbalLoad(array(array()), $container);
 
@@ -93,7 +94,7 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
         $loader = new DoctrineExtension();
         $container->registerExtension($loader);
 
-        $loadXml = new XmlFileLoader($container, __DIR__.'/Fixtures/config/xml');
+        $loadXml = new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/config/xml'));
         $loadXml->load('dbal_service_single_connection.xml');
         $loader->dbalLoad(array(array()), $container);
 

+ 2 - 1
src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/XmlDoctrineExtensionTest.php

@@ -13,12 +13,13 @@ namespace Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class XmlDoctrineExtensionTest extends AbstractDoctrineExtensionTest
 {
     protected function loadFromFile(ContainerBuilder $container, $file)
     {
-        $loadXml = new XmlFileLoader($container, __DIR__.'/Fixtures/config/xml');
+        $loadXml = new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/config/xml'));
         $loadXml->load($file.'.xml');
     }
 }

+ 2 - 1
src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/YamlDoctrineExtensionTest.php

@@ -13,12 +13,13 @@ namespace Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class YamlDoctrineExtensionTest extends AbstractDoctrineExtensionTest
 {
     protected function loadFromFile(ContainerBuilder $container, $file)
     {
-        $loadYaml = new YamlFileLoader($container, __DIR__.'/Fixtures/config/yml');
+        $loadYaml = new YamlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/config/yml'));
         $loadYaml->load($file.'.yml');
     }
 }

+ 2 - 1
src/Symfony/Bundle/DoctrineMongoDBBundle/DependencyInjection/DoctrineMongoDBExtension.php

@@ -13,6 +13,7 @@ namespace Symfony\Bundle\DoctrineMongoDBBundle\DependencyInjection;
 
 use Symfony\Component\HttpKernel\DependencyInjection\Extension;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Alias;
 use Symfony\Component\DependencyInjection\Reference;
@@ -64,7 +65,7 @@ class DoctrineMongoDBExtension extends AbstractDoctrineExtension
     {
         if (!$container->hasDefinition('doctrine.odm.mongodb.metadata.annotation')) {
             // Load DoctrineMongoDBBundle/Resources/config/mongodb.xml
-            $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
+            $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
             $loader->load('mongodb.xml');
         }
 

+ 0 - 2
src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/AbstractMongoDBExtensionTest.php

@@ -14,8 +14,6 @@ namespace Symfony\Bundle\DoctrineMongoDBBundle\Tests\DependencyInjection;
 use Symfony\Bundle\DoctrineMongoDBBundle\Tests\TestCase;
 use Symfony\Bundle\DoctrineMongoDBBundle\DependencyInjection\DoctrineMongoDBExtension;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
-use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
 use Symfony\Component\DependencyInjection\Reference;
 

+ 2 - 1
src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/XmlMongoDBExtensionTest.php

@@ -13,12 +13,13 @@ namespace Symfony\Bundle\DoctrineMongoDBBundle\Tests\DependencyInjection;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class XmlMongoDBExtensionTest extends AbstractMongoDBExtensionTest
 {
     protected function loadFromFile(ContainerBuilder $container, $file)
     {
-        $loadXml = new XmlFileLoader($container, __DIR__.'/Fixtures/config/xml');
+        $loadXml = new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/config/xml'));
         $loadXml->load($file.'.xml');
     }
 }

+ 2 - 1
src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/YamlMongoDBExtensionTest.php

@@ -13,12 +13,13 @@ namespace Symfony\Bundle\DoctrineMongoDBBundle\Tests\DependencyInjection;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class YamlMongoDBExtensionTest extends AbstractMongoDBExtensionTest
 {
     protected function loadFromFile(ContainerBuilder $container, $file)
     {
-        $loadYaml = new YamlFileLoader($container, __DIR__.'/Fixtures/config/yml');
+        $loadYaml = new YamlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/config/yml'));
         $loadYaml->load($file.'.yml');
     }
 }

+ 2 - 1
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

@@ -17,6 +17,7 @@ use Symfony\Component\DependencyInjection\Parameter;
 use Symfony\Component\DependencyInjection\Reference;
 use Symfony\Component\DependencyInjection\Configuration\Processor;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 use Symfony\Component\DependencyInjection\Resource\FileResource;
 use Symfony\Component\Finder\Finder;
 use Symfony\Component\HttpKernel\DependencyInjection\Extension;
@@ -37,7 +38,7 @@ class FrameworkExtension extends Extension
      */
     public function configLoad(array $configs, ContainerBuilder $container)
     {
-        $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
+        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
 
         $loader->load('web.xml');
         $loader->load('form.xml');

+ 2 - 1
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php

@@ -13,12 +13,13 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class PhpFrameworkExtensionTest extends FrameworkExtensionTest
 {
     protected function loadFromFile(ContainerBuilder $container, $file)
     {
-        $loader = new PhpFileLoader($container, __DIR__.'/Fixtures/php');
+        $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/Fixtures/php'));
         $loader->load($file.'.php');
     }
 }

+ 2 - 1
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php

@@ -13,12 +13,13 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class XmlFrameworkExtensionTest extends FrameworkExtensionTest
 {
     protected function loadFromFile(ContainerBuilder $container, $file)
     {
-        $loader = new XmlFileLoader($container, __DIR__.'/Fixtures/xml');
+        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/xml'));
         $loader->load($file.'.xml');
     }
 }

+ 2 - 1
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/YamlFrameworkExtensionTest.php

@@ -13,12 +13,13 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class YamlFrameworkExtensionTest extends FrameworkExtensionTest
 {
     protected function loadFromFile(ContainerBuilder $container, $file)
     {
-        $loader = new YamlFileLoader($container, __DIR__.'/Fixtures/yml');
+        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/yml'));
         $loader->load($file.'.yml');
     }
 }

+ 4 - 3
src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

@@ -17,6 +17,7 @@ use Symfony\Component\DependencyInjection\DefinitionDecorator;
 use Symfony\Component\DependencyInjection\Alias;
 use Symfony\Component\HttpKernel\DependencyInjection\Extension;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 use Symfony\Component\DependencyInjection\Resource\FileResource;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Reference;
@@ -56,7 +57,7 @@ class SecurityExtension extends Extension
         $config = $processor->process($tree, $configs);
 
         // load services
-        $loader = new XmlFileLoader($container, array(__DIR__.'/../Resources/config', __DIR__.'/Resources/config'));
+        $loader = new XmlFileLoader($container, new FileLocator(array(__DIR__.'/../Resources/config', __DIR__.'/Resources/config')));
         $loader->load('security.xml');
         $loader->load('security_listeners.xml');
         $loader->load('security_rememberme.xml');
@@ -82,7 +83,7 @@ class SecurityExtension extends Extension
         $processor = new Processor();
         $config = $processor->process($this->configuration->getAclConfigTree(), $configs);
 
-        $loader = new XmlFileLoader($container, array(__DIR__.'/../Resources/config', __DIR__.'/Resources/config'));
+        $loader = new XmlFileLoader($container, new FileLocator(array(__DIR__.'/../Resources/config', __DIR__.'/Resources/config')));
         $loader->load('security_acl.xml');
 
         if (isset($config['connection'])) {
@@ -551,7 +552,7 @@ class SecurityExtension extends Extension
         // load service templates
         $c = new ContainerBuilder();
         $parameterBag = $container->getParameterBag();
-        $loader = new XmlFileLoader($c, array(__DIR__.'/../Resources/config', __DIR__.'/Resources/config'));
+        $loader = new XmlFileLoader($c, new FileLocator(array(__DIR__.'/../Resources/config', __DIR__.'/Resources/config')));
         $loader->load('security_factories.xml');
 
         // load user-created listener factories

+ 2 - 1
src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/PhpSecurityExtensionTest.php

@@ -13,12 +13,13 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class PhpSecurityExtensionTest extends SecurityExtensionTest
 {
     protected function loadFromFile(ContainerBuilder $container, $file)
     {
-        $loadXml = new PhpFileLoader($container, __DIR__.'/Fixtures/php');
+        $loadXml = new PhpFileLoader($container, new FileLocator(__DIR__.'/Fixtures/php'));
         $loadXml->load($file.'.php');
     }
 }

+ 2 - 1
src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlSecurityExtensionTest.php

@@ -13,12 +13,13 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class XmlSecurityExtensionTest extends SecurityExtensionTest
 {
     protected function loadFromFile(ContainerBuilder $container, $file)
     {
-        $loadXml = new XmlFileLoader($container, __DIR__.'/Fixtures/xml');
+        $loadXml = new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/xml'));
         $loadXml->load($file.'.xml');
     }
 }

+ 2 - 1
src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/YamlSecurityExtensionTest.php

@@ -13,12 +13,13 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class YamlSecurityExtensionTest extends SecurityExtensionTest
 {
     protected function loadFromFile(ContainerBuilder $container, $file)
     {
-        $loadXml = new YamlFileLoader($container, __DIR__.'/Fixtures/yml');
+        $loadXml = new YamlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/yml'));
         $loadXml->load($file.'.yml');
     }
 }

+ 2 - 1
src/Symfony/Bundle/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php

@@ -13,6 +13,7 @@ namespace Symfony\Bundle\SwiftmailerBundle\DependencyInjection;
 
 use Symfony\Component\HttpKernel\DependencyInjection\Extension;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Reference;
 
@@ -47,7 +48,7 @@ class SwiftMailerExtension extends Extension
     protected function doConfigLoad(array $config, ContainerBuilder $container)
     {
         if (!$container->hasDefinition('swiftmailer.mailer')) {
-            $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
+            $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
             $loader->load('swiftmailer.xml');
             $container->setAlias('mailer', 'swiftmailer.mailer');
         }

+ 2 - 1
src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

@@ -15,6 +15,7 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 /**
  * TwigExtension.
@@ -25,7 +26,7 @@ class TwigExtension extends Extension
 {
     public function configLoad(array $configs, ContainerBuilder $container)
     {
-        $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
+        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
         $loader->load('twig.xml');
 
         $this->addClassesToCompile(array(

+ 3 - 2
src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php

@@ -13,6 +13,7 @@ namespace Symfony\Bundle\WebProfilerBundle\DependencyInjection;
 
 use Symfony\Component\HttpKernel\DependencyInjection\Extension;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 use Symfony\Component\DependencyInjection\Resource\FileResource;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Reference;
@@ -47,12 +48,12 @@ class WebProfilerExtension extends Extension
      */
     protected function doConfigLoad(array $config, ContainerBuilder $container)
     {
-        $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
+        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
 
         if (isset($config['toolbar'])) {
             if ($config['toolbar']) {
                 if (!$container->hasDefinition('debug.toolbar')) {
-                    $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
+                    $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
                     $loader->load('toolbar.xml');
                 }
             } elseif ($container->hasDefinition('debug.toolbar')) {

+ 2 - 1
src/Symfony/Bundle/ZendBundle/DependencyInjection/ZendExtension.php

@@ -13,6 +13,7 @@ namespace Symfony\Bundle\ZendBundle\DependencyInjection;
 
 use Symfony\Component\HttpKernel\DependencyInjection\Extension;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 
 /**
@@ -36,7 +37,7 @@ class ZendExtension extends Extension
      */
     public function configLoad(array $configs, ContainerBuilder $container)
     {
-        $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
+        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
         $loader->load('logger.xml');
         $container->setAlias('logger', 'zend.logger');
 

+ 9 - 62
src/Symfony/Component/DependencyInjection/Loader/FileLoader.php

@@ -20,24 +20,24 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
  */
 abstract class FileLoader extends Loader
 {
+    protected $locator;
     protected $currentDir;
-    protected $paths;
 
     /**
      * Constructor.
      *
      * @param ContainerBuilder $container A ContainerBuilder instance
-     * @param string|array     $paths A path or an array of paths where to look for resources
      */
-    public function __construct(ContainerBuilder $container, $paths = array())
+    public function __construct(ContainerBuilder $container, FileLocator $locator)
     {
-        parent::__construct($container);
+        $this->locator = $locator;
 
-        if (!is_array($paths)) {
-            $paths = array($paths);
-        }
+        parent::__construct($container);
+    }
 
-        $this->paths = $paths;
+    public function getLocator()
+    {
+        return $this->locator;
     }
 
     /**
@@ -51,7 +51,7 @@ abstract class FileLoader extends Loader
             $loader = $this->resolve($resource);
 
             if ($loader instanceof FileLoader && null !== $this->currentDir) {
-                $resource = $this->getAbsolutePath($resource, $this->currentDir);
+                $resource = $this->locator->getAbsolutePath($resource, $this->currentDir);
             }
 
             $loader->load($resource);
@@ -61,57 +61,4 @@ abstract class FileLoader extends Loader
             }
         }
     }
-
-    /**
-     * @throws \InvalidArgumentException When provided file does not exist
-     */
-    protected function findFile($file)
-    {
-        $path = $this->getAbsolutePath($file);
-        if (!file_exists($path)) {
-            throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (in: %s).', $file, implode(', ', $this->paths)));
-        }
-
-        return $path;
-    }
-
-    protected function getAbsolutePath($file, $currentPath = null)
-    {
-        if (self::isAbsolutePath($file)) {
-            return $file;
-        } else if (null !== $currentPath && file_exists($currentPath.DIRECTORY_SEPARATOR.$file)) {
-            return $currentPath.DIRECTORY_SEPARATOR.$file;
-        } else {
-            foreach ($this->paths as $path) {
-                if (file_exists($path.DIRECTORY_SEPARATOR.$file)) {
-                    return $path.DIRECTORY_SEPARATOR.$file;
-                }
-            }
-        }
-
-        return $file;
-    }
-
-    static protected function isAbsolutePath($file)
-    {
-        return
-            '/' == $file[0]
-            ||
-            '\\' == $file[0]
-            ||
-            (
-                3 < strlen($file)
-                &&
-                ctype_alpha($file[0])
-                &&
-                ':' == $file[1]
-                &&
-                (
-                    '\\' == $file[2]
-                    ||
-                    '/' == $file[2]
-                )
-            )
-        ;
-    }
 }

+ 101 - 0
src/Symfony/Component/DependencyInjection/Loader/FileLocator.php

@@ -0,0 +1,101 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DependencyInjection\Loader;
+
+/**
+ * FileLocator uses an array of pre-defined paths to find files.
+ *
+ * @author Fabien Potencier <fabien.potencier@symfony-project.com>
+ */
+class FileLocator
+{
+    protected $paths;
+
+    /**
+     * Constructor.
+     *
+     * @param string|array $paths A path or an array of paths where to look for resources
+     */
+    public function __construct($paths = array())
+    {
+        if (!is_array($paths)) {
+            $paths = array($paths);
+        }
+        $this->paths = $paths;
+    }
+
+    /**
+     * Returns a full path for a given file.
+     *
+     * @param string $file        A file path
+     * @param string $currentPath The current path
+     *
+     * @return string The full path for the file
+     *
+     * @throws \InvalidArgumentException When file is not found
+     */
+    public function locate($file, $currentPath = null)
+    {
+        $path = $this->getAbsolutePath($file, $currentPath);
+        if (!file_exists($path)) {
+            throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (in: %s).', $file, implode(', ', $this->paths)));
+        }
+
+        return $path;
+    }
+
+    /**
+     * Gets the absolute path for the file path if possible.
+     *
+     * @param string $file        A file path
+     * @param string $currentPath The current path
+     *
+     * @return string
+     */
+    public function getAbsolutePath($file, $currentPath = null)
+    {
+        if ($this->isAbsolutePath($file)) {
+            return $file;
+        } else if (null !== $currentPath && file_exists($currentPath.DIRECTORY_SEPARATOR.$file)) {
+            return $currentPath.DIRECTORY_SEPARATOR.$file;
+        } else {
+            foreach ($this->paths as $path) {
+                if (file_exists($path.DIRECTORY_SEPARATOR.$file)) {
+                    return $path.DIRECTORY_SEPARATOR.$file;
+                }
+            }
+        }
+
+        return $file;
+    }
+
+    /**
+     * Returns whether the file path is an absolute path.
+     *
+     * @param string $file A file path
+     *
+     * @return Boolean
+     */
+    public function isAbsolutePath($file)
+    {
+        if ($file[0] == '/' || $file[0] == '\\'
+            || (strlen($file) > 3 && ctype_alpha($file[0])
+                && $file[1] == ':'
+                && ($file[2] == '\\' || $file[2] == '/')
+            )
+        ) {
+            return true;
+        }
+
+        return false;
+    }
+}

+ 1 - 1
src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php

@@ -30,7 +30,7 @@ class IniFileLoader extends FileLoader
      */
     public function load($file)
     {
-        $path = $this->findFile($file);
+        $path = $this->locator->locate($file);
 
         $this->container->addResource(new FileResource($path));
 

+ 1 - 1
src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php

@@ -34,7 +34,7 @@ class PhpFileLoader extends FileLoader
         $container = $this->container;
         $loader = $this;
 
-        $path = $this->findFile($file);
+        $path = $this->locator->locate($file);
         $this->currentDir = dirname($path);
         $this->container->addResource(new FileResource($path));
 

+ 1 - 1
src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

@@ -36,7 +36,7 @@ class XmlFileLoader extends FileLoader
      */
     public function load($file)
     {
-        $path = $this->findFile($file);
+        $path = $this->locator->locate($file);
 
         $xml = $this->parseFile($path);
 

+ 1 - 1
src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

@@ -38,7 +38,7 @@ class YamlFileLoader extends FileLoader
      */
     public function load($file)
     {
-        $path = $this->findFile($file);
+        $path = $this->locator->locate($file);
 
         $content = $this->loadFile($path);
 

+ 50 - 0
src/Symfony/Component/HttpKernel/DependencyInjection/Loader/FileLocator.php

@@ -0,0 +1,50 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\HttpKernel\DependencyInjection\Loader;
+
+use Symfony\Component\DependencyInjection\Loader\FileLocator as BaseFileLocator;
+use Symfony\Component\HttpKernel\KernelInterface;
+
+/**
+ * FileLocator uses the KernelInterface to locate resources in bundles.
+ *
+ * @author Fabien Potencier <fabien.potencier@symfony-project.com>
+ */
+class FileLocator extends BaseFileLocator
+{
+    protected $kernel;
+
+    /**
+     * Constructor.
+     *
+     * @param KernelInterface $kernel A KernelInterface instance
+     * @param string|array    $paths  A path or an array of paths where to look for resources
+     */
+    public function __construct(KernelInterface $kernel, array $paths = array())
+    {
+        $this->kernel = $kernel;
+
+        parent::__construct($paths);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function locate($file, $currentPath = null)
+    {
+        if ('@' === $file[0]) {
+            return $this->kernel->locateResource($file);
+        }
+
+        return parent::locate($file, $currentPath);
+    }
+}

+ 7 - 6
src/Symfony/Component/HttpKernel/Kernel.php

@@ -16,8 +16,8 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
 use Symfony\Component\DependencyInjection\Loader\DelegatingLoader;
-use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
 use Symfony\Component\DependencyInjection\Loader\LoaderInterface;
+use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
 use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
@@ -26,6 +26,7 @@ use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
 use Symfony\Component\HttpKernel\Bundle\BundleInterface;
+use Symfony\Component\HttpKernel\DependencyInjection\Loader\FileLocator;
 
 /**
  * The Kernel is the heart of the Symfony system.
@@ -523,11 +524,11 @@ abstract class Kernel implements KernelInterface
     protected function getContainerLoader(ContainerInterface $container)
     {
         $resolver = new LoaderResolver(array(
-            new XmlFileLoader($container),
-            new YamlFileLoader($container),
-            new IniFileLoader($container),
-            new PhpFileLoader($container),
-            new ClosureLoader($container),
+            new XmlFileLoader($container, new FileLocator($this)),
+            new YamlFileLoader($container, new FileLocator($this)),
+            new IniFileLoader($container, new FileLocator($this)),
+            new PhpFileLoader($container, new FileLocator($this)),
+            new ClosureLoader($container, new FileLocator($this)),
         ));
 
         return new DelegatingLoader($resolver);

+ 17 - 13
src/Symfony/Component/HttpKernel/bootstrap.php

@@ -469,8 +469,8 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
 use Symfony\Component\DependencyInjection\Loader\DelegatingLoader;
-use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
 use Symfony\Component\DependencyInjection\Loader\LoaderInterface;
+use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
 use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
@@ -479,6 +479,7 @@ use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
 use Symfony\Component\HttpKernel\Bundle\BundleInterface;
+use Symfony\Component\HttpKernel\DependencyInjection\Loader\FileLocator;
 abstract class Kernel implements KernelInterface
 {
     protected $bundles;
@@ -521,7 +522,7 @@ abstract class Kernel implements KernelInterface
         }
                 $this->initializeBundles();
                 $this->initializeContainer();
-        foreach ($this->bundles as $bundle) {
+        foreach ($this->getBundles() as $bundle) {
             $bundle->setContainer($this->container);
             $bundle->boot();
         }
@@ -530,7 +531,7 @@ abstract class Kernel implements KernelInterface
     public function shutdown()
     {
         $this->booted = false;
-        foreach ($this->bundles as $bundle) {
+        foreach ($this->getBundles() as $bundle) {
             $bundle->shutdown();
             $bundle->setContainer(null);
         }
@@ -541,7 +542,11 @@ abstract class Kernel implements KernelInterface
         if (false === $this->booted) {
             $this->boot();
         }
-        return $this->container->get('http_kernel')->handle($request, $type, $catch);
+        return $this->getHttpKernel()->handle($request, $type, $catch);
+    }
+    protected function getHttpKernel()
+    {
+        return $this->container->get('http_kernel');
     }
     public function getBundles()
     {
@@ -549,9 +554,8 @@ abstract class Kernel implements KernelInterface
     }
     public function isClassInActiveBundle($class)
     {
-        foreach ($this->bundles as $bundle) {
-            $bundleClass = get_class($bundle);
-            if (0 === strpos($class, substr($bundleClass, 0, strrpos($bundleClass, '\\')))) {
+        foreach ($this->getBundles() as $bundle) {
+            if (0 === strpos($class, $bundle->getNamespace())) {
                 return true;
             }
         }
@@ -651,7 +655,7 @@ abstract class Kernel implements KernelInterface
                 $topMostBundles[$name] = $bundle;
             }
         }
-                if (count($diff = array_diff(array_keys($directChildren), array_keys($this->bundles)))) {
+                if (count($diff = array_values(array_diff(array_keys($directChildren), array_keys($this->bundles))))) {
             throw new \LogicException(sprintf('Bundle "%s" extends bundle "%s", which is not registered.', $directChildren[$diff[0]], $diff[0]));
         }
                 $this->bundleMap = array();
@@ -773,11 +777,11 @@ abstract class Kernel implements KernelInterface
     protected function getContainerLoader(ContainerInterface $container)
     {
         $resolver = new LoaderResolver(array(
-            new XmlFileLoader($container),
-            new YamlFileLoader($container),
-            new IniFileLoader($container),
-            new PhpFileLoader($container),
-            new ClosureLoader($container),
+            new XmlFileLoader($container, new FileLocator($this)),
+            new YamlFileLoader($container, new FileLocator($this)),
+            new IniFileLoader($container, new FileLocator($this)),
+            new PhpFileLoader($container, new FileLocator($this)),
+            new ClosureLoader($container, new FileLocator($this)),
         ));
         return new DelegatingLoader($resolver);
     }

+ 67 - 21
src/Symfony/Component/HttpKernel/bootstrap_cache.php

@@ -33,8 +33,8 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
 use Symfony\Component\DependencyInjection\Loader\DelegatingLoader;
-use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
 use Symfony\Component\DependencyInjection\Loader\LoaderInterface;
+use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
 use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
@@ -43,6 +43,7 @@ use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
 use Symfony\Component\HttpKernel\Bundle\BundleInterface;
+use Symfony\Component\HttpKernel\DependencyInjection\Loader\FileLocator;
 abstract class Kernel implements KernelInterface
 {
     protected $bundles;
@@ -85,7 +86,7 @@ abstract class Kernel implements KernelInterface
         }
                 $this->initializeBundles();
                 $this->initializeContainer();
-        foreach ($this->bundles as $bundle) {
+        foreach ($this->getBundles() as $bundle) {
             $bundle->setContainer($this->container);
             $bundle->boot();
         }
@@ -94,7 +95,7 @@ abstract class Kernel implements KernelInterface
     public function shutdown()
     {
         $this->booted = false;
-        foreach ($this->bundles as $bundle) {
+        foreach ($this->getBundles() as $bundle) {
             $bundle->shutdown();
             $bundle->setContainer(null);
         }
@@ -105,7 +106,11 @@ abstract class Kernel implements KernelInterface
         if (false === $this->booted) {
             $this->boot();
         }
-        return $this->container->get('http_kernel')->handle($request, $type, $catch);
+        return $this->getHttpKernel()->handle($request, $type, $catch);
+    }
+    protected function getHttpKernel()
+    {
+        return $this->container->get('http_kernel');
     }
     public function getBundles()
     {
@@ -113,9 +118,8 @@ abstract class Kernel implements KernelInterface
     }
     public function isClassInActiveBundle($class)
     {
-        foreach ($this->bundles as $bundle) {
-            $bundleClass = get_class($bundle);
-            if (0 === strpos($class, substr($bundleClass, 0, strrpos($bundleClass, '\\')))) {
+        foreach ($this->getBundles() as $bundle) {
+            if (0 === strpos($class, $bundle->getNamespace())) {
                 return true;
             }
         }
@@ -215,7 +219,7 @@ abstract class Kernel implements KernelInterface
                 $topMostBundles[$name] = $bundle;
             }
         }
-                if (count($diff = array_diff(array_keys($directChildren), array_keys($this->bundles)))) {
+                if (count($diff = array_values(array_diff(array_keys($directChildren), array_keys($this->bundles))))) {
             throw new \LogicException(sprintf('Bundle "%s" extends bundle "%s", which is not registered.', $directChildren[$diff[0]], $diff[0]));
         }
                 $this->bundleMap = array();
@@ -337,11 +341,11 @@ abstract class Kernel implements KernelInterface
     protected function getContainerLoader(ContainerInterface $container)
     {
         $resolver = new LoaderResolver(array(
-            new XmlFileLoader($container),
-            new YamlFileLoader($container),
-            new IniFileLoader($container),
-            new PhpFileLoader($container),
-            new ClosureLoader($container),
+            new XmlFileLoader($container, new FileLocator($this)),
+            new YamlFileLoader($container, new FileLocator($this)),
+            new IniFileLoader($container, new FileLocator($this)),
+            new PhpFileLoader($container, new FileLocator($this)),
+            new ClosureLoader($container, new FileLocator($this)),
         ));
         return new DelegatingLoader($resolver);
     }
@@ -403,6 +407,7 @@ class HttpCache implements HttpKernelInterface
     protected $store;
     protected $request;
     protected $esi;
+    protected $esiTtls;
     public function __construct(HttpKernelInterface $kernel, StoreInterface $store, Esi $esi = null, array $options = array())
     {
         $this->store = $store;
@@ -440,6 +445,7 @@ class HttpCache implements HttpKernelInterface
                 if (HttpKernelInterface::MASTER_REQUEST === $type) {
             $this->traces = array();
             $this->request = $request;
+            $this->esiTtls = array();
         }
         $path = $request->getPathInfo();
         if ($qs = $request->getQueryString()) {
@@ -458,8 +464,28 @@ class HttpCache implements HttpKernelInterface
         if (HttpKernelInterface::MASTER_REQUEST === $type && $this->options['debug']) {
             $response->headers->set('X-Symfony-Cache', $this->getLog());
         }
+        if (null !== $this->esi) {
+            $this->addEsiTtl($response);
+            if ($request === $this->request) {
+                $this->updateResponseCacheControl($response);
+            }
+        }
         return $response;
     }
+    protected function addEsiTtl(Response $response)
+    {
+        $this->esiTtls[] = $response->isValidateable() ? -1 : $response->getTtl();
+    }
+    protected function updateResponseCacheControl(Response $response)
+    {
+        $ttl = min($this->esiTtls);
+        if (-1 === $ttl) {
+            $response->headers->set('Cache-Control', 'no-cache, must-revalidate');
+        } else {
+            $response->setSharedMaxAge($ttl);
+            $response->setMaxAge(0);
+        }
+    }
     protected function pass(Request $request, $catch = false)
     {
         $this->record($request, 'pass');
@@ -1459,14 +1485,34 @@ class Request
     public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
     {
         $dup = clone $this;
-        $dup->initialize(
-            null !== $query ? $query : $this->query->all(),
-            null !== $request ? $request : $this->request->all(),
-            null !== $attributes ? $attributes : $this->attributes->all(),
-            null !== $cookies ? $cookies : $this->cookies->all(),
-            null !== $files ? $files : $this->files->all(),
-            null !== $server ? $server : $this->server->all()
-        );
+        if ($query !== null) {
+          $dup->query = new ParameterBag($query);
+        }
+        if ($request !== null) {
+          $dup->request = new ParameterBag($request);
+        }
+        if ($attributes !== null) {
+          $dup->attributes = new ParameterBag($attributes);
+        }
+        if ($cookies !== null) {
+          $dup->cookies = new ParameterBag($cookies);
+        }
+        if ($files !== null) {
+          $dup->files = new FileBag($files);
+        }
+        if ($server !== null) {
+          $dup->server = new ServerBag($server);
+          $dup->headers = new HeaderBag($dup->server->getHeaders());
+        }
+        $this->languages = null;
+        $this->charsets = null;
+        $this->acceptableContentTypes = null;
+        $this->pathInfo = null;
+        $this->requestUri = null;
+        $this->baseUrl = null;
+        $this->basePath = null;
+        $this->method = null;
+        $this->format = null;
         return $dup;
     }
     public function __clone()

+ 3 - 2
tests/Symfony/Tests/Component/DependencyInjection/CrossCheckTest.php

@@ -12,6 +12,7 @@
 namespace Symfony\Tests\Component\DependencyInjection;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class CrossCheckTest extends \PHPUnit_Framework_TestCase
 {
@@ -38,14 +39,14 @@ class CrossCheckTest extends \PHPUnit_Framework_TestCase
         file_put_contents($tmp, file_get_contents(self::$fixturesPath.'/'.$type.'/'.$fixture));
 
         $container1 = new ContainerBuilder();
-        $loader1 = new $loaderClass($container1);
+        $loader1 = new $loaderClass($container1, new FileLocator());
         $loader1->load($tmp);
 
         $dumper = new $dumperClass($container1);
         file_put_contents($tmp, $dumper->dump());
 
         $container2 = new ContainerBuilder();
-        $loader2 = new $loaderClass($container2);
+        $loader2 = new $loaderClass($container2, new FileLocator());
         $loader2->load($tmp);
 
         unlink($tmp);

+ 2 - 1
tests/Symfony/Tests/Component/DependencyInjection/Loader/DelegatingLoaderTest.php

@@ -16,6 +16,7 @@ use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
 use Symfony\Component\DependencyInjection\Loader\DelegatingLoader;
 use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
 use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
 {
@@ -49,7 +50,7 @@ class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase
     {
         $container = new ContainerBuilder();
         $resolver = new LoaderResolver(array(
-            $ini = new IniFileLoader($container, array()),
+            $ini = new IniFileLoader($container, new FileLocator(array())),
         ));
         $loader = new DelegatingLoader($resolver);
 

+ 5 - 36
tests/Symfony/Tests/Component/DependencyInjection/Loader/FileLoaderTest.php

@@ -12,56 +12,25 @@
 namespace Symfony\Tests\Component\DependencyInjection\Loader;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\DependencyInjection\Loader\FileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
-class FileLoaderTest extends \PHPUnit_Framework_TestCase
+class FileLocatorTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @covers Symfony\Component\DependencyInjection\Loader\FileLoader::__construct
-     */
-    public function testConstructor()
-    {
-        $loader = new ProjectLoader(new ContainerBuilder(), __DIR__);
-        $this->assertEquals(array(__DIR__), $loader->paths, '__construct() takes a path as its second argument');
-
-        $loader = new ProjectLoader(new ContainerBuilder(), array(__DIR__, __DIR__));
-        $this->assertEquals(array(__DIR__, __DIR__), $loader->paths, '__construct() takes an array of paths as its second argument');
-    }
-
-    /**
-     * @covers Symfony\Component\DependencyInjection\Loader\FileLoader::GetAbsolutePath
+     * @covers Symfony\Component\DependencyInjection\Loader\FileLocator::GetAbsolutePath
      */
     public function testGetAbsolutePath()
     {
-        $loader = new ProjectLoader(new ContainerBuilder(), array(__DIR__.'/../Fixtures/containers'));
+        $loader = new FileLocator(array(__DIR__.'/../Fixtures/containers'));
         $this->assertEquals('/foo.xml', $loader->getAbsolutePath('/foo.xml'), '->getAbsolutePath() return the path unmodified if it is already an absolute path');
         $this->assertEquals('c:\\\\foo.xml', $loader->getAbsolutePath('c:\\\\foo.xml'), '->getAbsolutePath() return the path unmodified if it is already an absolute path');
         $this->assertEquals('c:/foo.xml', $loader->getAbsolutePath('c:/foo.xml'), '->getAbsolutePath() return the path unmodified if it is already an absolute path');
         $this->assertEquals('\\server\\foo.xml', $loader->getAbsolutePath('\\server\\foo.xml'), '->getAbsolutePath() return the path unmodified if it is already an absolute path');
 
-        $this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'FileLoaderTest.php', $loader->getAbsolutePath('FileLoaderTest.php', __DIR__), '->getAbsolutePath() returns an absolute filename if the file exists in the current path');
+        $this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'FileLocatorTest.php', $loader->getAbsolutePath('FileLocatorTest.php', __DIR__), '->getAbsolutePath() returns an absolute filename if the file exists in the current path');
 
         $this->assertEquals(__DIR__.'/../Fixtures/containers'.DIRECTORY_SEPARATOR.'container10.php', $loader->getAbsolutePath('container10.php', __DIR__), '->getAbsolutePath() returns an absolute filename if the file exists in one of the paths given in the constructor');
 
         $this->assertEquals('foo.xml', $loader->getAbsolutePath('foo.xml', __DIR__), '->getAbsolutePath() returns the path unmodified if it is unable to find it in the given paths');
     }
 }
-
-class ProjectLoader extends FileLoader
-{
-    public $paths;
-
-    public function load($resource, ContainerBuilder $container = null)
-    {
-    }
-
-    public function supports($resource)
-    {
-        return true;
-    }
-
-    public function getAbsolutePath($file, $currentPath = null)
-    {
-        return parent::getAbsolutePath($file, $currentPath);
-    }
-}

+ 3 - 2
tests/Symfony/Tests/Component/DependencyInjection/Loader/IniFileLoaderTest.php

@@ -13,6 +13,7 @@ namespace Symfony\Tests\Component\DependencyInjection\Loader;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class IniFileLoaderTest extends \PHPUnit_Framework_TestCase
 {
@@ -30,7 +31,7 @@ class IniFileLoaderTest extends \PHPUnit_Framework_TestCase
     public function testLoader()
     {
         $container = new ContainerBuilder();
-        $loader = new IniFileLoader($container, self::$fixturesPath.'/ini');
+        $loader = new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/ini'));
         $loader->load('parameters.ini');
         $this->assertEquals(array('foo' => 'bar', 'bar' => '%foo%'), $container->getParameterBag()->all(), '->load() takes a single file name as its first argument');
 
@@ -56,7 +57,7 @@ class IniFileLoaderTest extends \PHPUnit_Framework_TestCase
      */
     public function testSupports()
     {
-        $loader = new IniFileLoader(new ContainerBuilder());
+        $loader = new IniFileLoader(new ContainerBuilder(), new FileLocator());
 
         $this->assertTrue($loader->supports('foo.ini'), '->supports() returns true if the resource is loadable');
         $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');

+ 2 - 1
tests/Symfony/Tests/Component/DependencyInjection/Loader/LoaderTest.php

@@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
 use Symfony\Component\DependencyInjection\Loader\Loader;
 use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class LoaderTest extends \PHPUnit_Framework_TestCase
 {
@@ -47,7 +48,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
         $container = new ContainerBuilder();
 
         $resolver = new LoaderResolver(array(
-            $ini = new IniFileLoader($container, array()),
+            $ini = new IniFileLoader($container, new FileLocator(array())),
         ));
         $loader = new ProjectLoader1($container);
         $loader->setResolver($resolver);

+ 3 - 2
tests/Symfony/Tests/Component/DependencyInjection/Loader/PhpFileLoaderTest.php

@@ -17,6 +17,7 @@ use Symfony\Component\DependencyInjection\Definition;
 use Symfony\Component\DependencyInjection\Loader\Loader;
 use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
 use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase
 {
@@ -25,7 +26,7 @@ class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase
      */
     public function testSupports()
     {
-        $loader = new PhpFileLoader(new ContainerBuilder());
+        $loader = new PhpFileLoader(new ContainerBuilder(), new FileLocator());
 
         $this->assertTrue($loader->supports('foo.php'), '->supports() returns true if the resource is loadable');
         $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
@@ -36,7 +37,7 @@ class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase
      */
     public function testLoad()
     {
-        $loader = new PhpFileLoader($container = new ContainerBuilder());
+        $loader = new PhpFileLoader($container = new ContainerBuilder(), new FileLocator());
 
         $loader->load(__DIR__.'/../Fixtures/php/simple.php');
 

+ 16 - 15
tests/Symfony/Tests/Component/DependencyInjection/Loader/XmlFileLoaderTest.php

@@ -21,6 +21,7 @@ use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
 use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
 use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
 {
@@ -37,7 +38,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
 
     public function testLoad()
     {
-        $loader = new ProjectLoader2(new ContainerBuilder(), self::$fixturesPath.'/ini');
+        $loader = new ProjectLoader2(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/ini'));
 
         try {
             $loader->load('foo.xml');
@@ -50,7 +51,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
 
     public function testParseFile()
     {
-        $loader = new ProjectLoader2(new ContainerBuilder(), self::$fixturesPath.'/ini');
+        $loader = new ProjectLoader2(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/ini'));
 
         try {
             $loader->parseFile(self::$fixturesPath.'/ini/parameters.ini');
@@ -60,7 +61,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
             $this->assertStringStartsWith('[ERROR 4] Start tag expected, \'<\' not found (in', $e->getMessage(), '->parseFile() throws an InvalidArgumentException if the loaded file is not a valid XML file');
         }
 
-        $loader = new ProjectLoader2(new ContainerBuilder(), self::$fixturesPath.'/xml');
+        $loader = new ProjectLoader2(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/xml'));
 
         try {
             $loader->parseFile(self::$fixturesPath.'/xml/nonvalid.xml');
@@ -77,7 +78,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
     public function testLoadParameters()
     {
         $container = new ContainerBuilder();
-        $loader = new ProjectLoader2($container, self::$fixturesPath.'/xml');
+        $loader = new ProjectLoader2($container, new FileLocator(self::$fixturesPath.'/xml'));
         $loader->load('services2.xml');
 
         $actual = $container->getParameterBag()->all();
@@ -90,9 +91,9 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
     {
         $container = new ContainerBuilder();
         $resolver = new LoaderResolver(array(
-            new IniFileLoader($container, self::$fixturesPath.'/xml'),
-            new YamlFileLoader($container, self::$fixturesPath.'/xml'),
-            $loader = new ProjectLoader2($container, self::$fixturesPath.'/xml'),
+            new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')),
+            new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')),
+            $loader = new ProjectLoader2($container, new FileLocator(self::$fixturesPath.'/xml')),
         ));
         $loader->setResolver($resolver);
         $loader->load('services4.xml');
@@ -106,7 +107,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
     public function testLoadAnonymousServices()
     {
         $container = new ContainerBuilder();
-        $loader = new ProjectLoader2($container, self::$fixturesPath.'/xml');
+        $loader = new ProjectLoader2($container, new FileLocator(self::$fixturesPath.'/xml'));
         $loader->load('services5.xml');
         $services = $container->getDefinitions();
         $this->assertEquals(3, count($services), '->load() attributes unique ids to anonymous services');
@@ -128,7 +129,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
     public function testLoadServices()
     {
         $container = new ContainerBuilder();
-        $loader = new ProjectLoader2($container, self::$fixturesPath.'/xml');
+        $loader = new ProjectLoader2($container, new FileLocator(self::$fixturesPath.'/xml'));
         $loader->load('services6.xml');
         $services = $container->getDefinitions();
         $this->assertTrue(isset($services['foo']), '->load() parses <service> elements');
@@ -194,7 +195,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
         $container = new ContainerBuilder();
         $container->registerExtension(new \ProjectExtension());
         $container->registerExtension(new \ProjectWithXsdExtension());
-        $loader = new ProjectLoader2($container, self::$fixturesPath.'/xml');
+        $loader = new ProjectLoader2($container, new FileLocator(self::$fixturesPath.'/xml'));
 
         // extension without an XSD
         $loader->load('extensions/services1.xml');
@@ -212,7 +213,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
         $container = new ContainerBuilder();
         $container->registerExtension(new \ProjectExtension());
         $container->registerExtension(new \ProjectWithXsdExtension());
-        $loader = new ProjectLoader2($container, self::$fixturesPath.'/xml');
+        $loader = new ProjectLoader2($container, new FileLocator(self::$fixturesPath.'/xml'));
         $loader->load('extensions/services2.xml');
         $container->compile();
         $services = $container->getDefinitions();
@@ -224,7 +225,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals('BAR', $services['project.service.foo']->getClass(), '->load() parses extension elements');
         $this->assertEquals('BAR', $parameters['project.parameter.foo'], '->load() parses extension elements');
 
-        $loader = new ProjectLoader2(new ContainerBuilder(), self::$fixturesPath.'/xml');
+        $loader = new ProjectLoader2(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/xml'));
 
         // extension with an XSD (does not validate)
         try {
@@ -250,7 +251,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
         // extension with an XSD in PHAR archive
         $container = new ContainerBuilder();
         $container->registerExtension(new \ProjectWithXsdExtensionInPhar());
-        $loader = new ProjectLoader2($container, self::$fixturesPath.'/xml');
+        $loader = new ProjectLoader2($container, new FileLocator(self::$fixturesPath.'/xml'));
         $loader->load('extensions/services6.xml');
 
         // extension with an XSD in PHAR archive (does not validate)
@@ -268,7 +269,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
      */
     public function testSupports()
     {
-        $loader = new XmlFileLoader(new ContainerBuilder());
+        $loader = new XmlFileLoader(new ContainerBuilder(), new FileLocator());
 
         $this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable');
         $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
@@ -277,7 +278,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
     public function testLoadInterfaceInjectors()
     {
         $container = new ContainerBuilder();
-        $loader = new ProjectLoader2($container, self::$fixturesPath.'/xml');
+        $loader = new ProjectLoader2($container, new FileLocator(self::$fixturesPath.'/xml'));
         $loader->load('interfaces1.xml');
         $interfaces = $container->getInterfaceInjectors('FooClass');
         $this->assertEquals(1, count($interfaces), '->load() parses <interface> elements');

+ 11 - 10
tests/Symfony/Tests/Component/DependencyInjection/Loader/YamlFileLoaderTest.php

@@ -19,6 +19,7 @@ use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
 use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
 use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
+use Symfony\Component\DependencyInjection\Loader\FileLocator;
 
 class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
 {
@@ -33,7 +34,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
 
     public function testLoadFile()
     {
-        $loader = new ProjectLoader3(new ContainerBuilder(), self::$fixturesPath.'/ini');
+        $loader = new ProjectLoader3(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/ini'));
 
         try {
             $loader->loadFile('foo.yml');
@@ -51,7 +52,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
             $this->assertEquals('The service file "parameters.ini" is not valid.', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file is not a valid YAML file');
         }
 
-        $loader = new ProjectLoader3(new ContainerBuilder(), self::$fixturesPath.'/yaml');
+        $loader = new ProjectLoader3(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
 
         foreach (array('nonvalid1', 'nonvalid2') as $fixture) {
             try {
@@ -67,7 +68,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
     public function testLoadParameters()
     {
         $container = new ContainerBuilder();
-        $loader = new ProjectLoader3($container, self::$fixturesPath.'/yaml');
+        $loader = new ProjectLoader3($container, new FileLocator(self::$fixturesPath.'/yaml'));
         $loader->load('services2.yml');
         $this->assertEquals(array('foo' => 'bar', 'values' => array(true, false, 0, 1000.3), 'bar' => 'foo', 'foo_bar' => new Reference('foo_bar')), $container->getParameterBag()->all(), '->load() converts YAML keys to lowercase');
     }
@@ -76,9 +77,9 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
     {
         $container = new ContainerBuilder();
         $resolver = new LoaderResolver(array(
-            new IniFileLoader($container, self::$fixturesPath.'/yaml'),
-            new XmlFileLoader($container, self::$fixturesPath.'/yaml'),
-            $loader = new ProjectLoader3($container, self::$fixturesPath.'/yaml'),
+            new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')),
+            new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')),
+            $loader = new ProjectLoader3($container, new FileLocator(self::$fixturesPath.'/yaml')),
         ));
         $loader->setResolver($resolver);
         $loader->load('services4.yml');
@@ -91,7 +92,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
     public function testLoadServices()
     {
         $container = new ContainerBuilder();
-        $loader = new ProjectLoader3($container, self::$fixturesPath.'/yaml');
+        $loader = new ProjectLoader3($container, new FileLocator(self::$fixturesPath.'/yaml'));
         $loader->load('services6.yml');
         $services = $container->getDefinitions();
         $this->assertTrue(isset($services['foo']), '->load() parses service elements');
@@ -123,7 +124,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
     {
         $container = new ContainerBuilder();
         $container->registerExtension(new \ProjectExtension());
-        $loader = new ProjectLoader3($container, self::$fixturesPath.'/yaml');
+        $loader = new ProjectLoader3($container, new FileLocator(self::$fixturesPath.'/yaml'));
         $loader->load('services10.yml');
         $container->compile();
         $services = $container->getDefinitions();
@@ -157,7 +158,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
      */
     public function testSupports()
     {
-        $loader = new YamlFileLoader(new ContainerBuilder());
+        $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator());
 
         $this->assertTrue($loader->supports('foo.yml'), '->supports() returns true if the resource is loadable');
         $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
@@ -166,7 +167,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
     public function testLoadInterfaceInjectors()
     {
         $container = new ContainerBuilder();
-        $loader = new ProjectLoader3($container, self::$fixturesPath.'/yaml');
+        $loader = new ProjectLoader3($container, new FileLocator(self::$fixturesPath.'/yaml'));
         $loader->load('interfaces1.yml');
         $interfaces = $container->getInterfaceInjectors('FooClass');
         $this->assertEquals(1, count($interfaces), '->load() parses interfaces');