[FrameworkBundle] added 'document_root' option for File objects

This commit is contained in:
Bulat Shakirzyanov 2011-01-18 14:18:28 -05:00 committed by Fabien Potencier
parent bdc7ae8c52
commit acb19bc43f
2 changed files with 11 additions and 0 deletions

View File

@ -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');

View File

@ -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')) {