Explorar o código

[FrameworkBundle] added 'document_root' option for File objects

Bulat Shakirzyanov %!s(int64=14) %!d(string=hai) anos
pai
achega
acb19bc43f

+ 6 - 0
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

@@ -85,6 +85,12 @@ class FrameworkExtension extends Extension
             $container->setParameter('debug.file_link_format', $pattern);
         }
 
+        foreach (array('document_root', 'document-root') as $key) {
+            if (isset($config[$key])) {
+                $container->setParameter('document_root', $config[$key]);
+            }
+        }
+
         if (!$container->hasDefinition('event_dispatcher')) {
             $loader = new XmlFileLoader($container, array(__DIR__.'/../Resources/config', __DIR__.'/Resources/config'));
             $loader->load('services.xml');

+ 5 - 0
src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

@@ -23,6 +23,7 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddClassesToCach
 use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Compiler\PassConfig;
+use Symfony\Component\HttpFoundation\File\File;
 use Symfony\Component\HttpKernel\Bundle\Bundle;
 
 /**
@@ -43,6 +44,10 @@ class FrameworkBundle extends Bundle
             $container->get('error_handler');
         }
 
+        if ($this->container->hasParameter('document_root')) {
+            File::setDocumentRoot($this->container->getParameter('document_root'));
+        }
+
         // the session ID should always be included in the CSRF token, even
         // if default CSRF protection is not enabled
         if ($container->has('form.default_context') && $container->has('session')) {