diff --git a/UPDATE.md b/UPDATE.md index 83eb929aec..6b11e56f65 100644 --- a/UPDATE.md +++ b/UPDATE.md @@ -9,6 +9,8 @@ timeline closely anyway. PR12 to beta1 ------------- +* The `File::getWebPath()` method has been removed. + * The `session` configuration has been refactored: * The `class` option has been removed (use the `session.class` parameter diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 7e8ad2e59e..d9e39a3909 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -39,7 +39,6 @@ class Configuration implements ConfigurationInterface ->children() ->scalarNode('cache_warmer')->defaultValue(!$this->debug)->end() ->scalarNode('charset')->end() - ->scalarNode('document_root')->end() ->scalarNode('error_handler')->end() ->scalarNode('exception_controller')->defaultValue('Symfony\\Bundle\\FrameworkBundle\\Controller\\ExceptionController::showAction')->end() ->scalarNode('ide')->defaultNull()->end() diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index c3cd5899b7..a95bf273aa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -65,10 +65,6 @@ class FrameworkExtension extends Extension $container->setParameter('kernel.charset', $config['charset']); } - if (isset($config['document_root'])) { - $container->setParameter('document_root', $config['document_root']); - } - if (isset($config['error_handler'])) { if (false === $config['error_handler']) { $container->getDefinition('error_handler')->setMethodCalls(array()); diff --git a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php index 9abbb5ec0f..9a06ff198e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php @@ -56,10 +56,6 @@ class FrameworkBundle extends Bundle $this->container->get('error_handler'); } - if ($this->container->hasParameter('document_root')) { - File::setDocumentRoot($this->container->getParameter('document_root')); - } - if (file_exists($this->container->getParameter('kernel.cache_dir').'/autoload.php')) { $classloader = new MapFileClassLoader($this->container->getParameter('kernel.cache_dir').'/autoload.php'); $classloader->register(true); diff --git a/src/Symfony/Component/HttpFoundation/File/File.php b/src/Symfony/Component/HttpFoundation/File/File.php index bda63e9a6b..cd12de9067 100644 --- a/src/Symfony/Component/HttpFoundation/File/File.php +++ b/src/Symfony/Component/HttpFoundation/File/File.php @@ -440,13 +440,6 @@ class File 'x-world/x-vrml' => 'wrl', ); - /** - * Stores the absolute path to the document root directory. - * - * @var string - */ - static protected $documentRoot; - /** * The absolute path to the file without dots. * @@ -454,30 +447,6 @@ class File */ protected $path; - /** - * Sets the path to the document root directory. - * - * @param string $documentRoot - */ - static public function setDocumentRoot($documentRoot) - { - if (!is_dir($documentRoot)) { - throw new \LogicException($documentRoot . ' is not a directory.'); - } - - self::$documentRoot = realpath($documentRoot); - } - - /** - * Returns the path to the document root directory. - * - * @return string - */ - static public function getDocumentRoot() - { - return self::$documentRoot; - } - /** * Constructs a new file from the given path. * @@ -566,26 +535,6 @@ class File return $this->path; } - /** - * Returns the path relative to the document root. - * - * You can set the document root using the static method setDocumentRoot(). - * If the file is outside of the document root, this method returns an - * empty string. - * - * @return string The relative file path - */ - public function getWebPath() - { - $root = self::$documentRoot; - - if (false === strpos($this->path, $root)) { - return ''; - } - - return str_replace(array($root, DIRECTORY_SEPARATOR), array('', '/'), $this->path); - } - /** * Returns the mime type of the file. * diff --git a/tests/Symfony/Tests/Component/HttpFoundation/File/FileTest.php b/tests/Symfony/Tests/Component/HttpFoundation/File/FileTest.php index 6f7c936a0a..d1d9c709bd 100644 --- a/tests/Symfony/Tests/Component/HttpFoundation/File/FileTest.php +++ b/tests/Symfony/Tests/Component/HttpFoundation/File/FileTest.php @@ -33,28 +33,6 @@ class FileTest extends \PHPUnit_Framework_TestCase $this->assertEquals(__DIR__.'/Fixtures/test.gif', (string) $this->file); } - public function testGetWebPathReturnsPathRelativeToDocumentRoot() - { - File::setDocumentRoot(__DIR__); - - $this->assertEquals(__DIR__, File::getDocumentRoot()); - $this->assertEquals('/Fixtures/test.gif', $this->file->getWebPath()); - } - - public function testGetWebPathReturnsEmptyPathIfOutsideDocumentRoot() - { - File::setDocumentRoot(__DIR__.'/Fixtures/directory'); - - $this->assertEquals('', $this->file->getWebPath()); - } - - public function testSetDocumentRootThrowsLogicExceptionWhenNotExists() - { - $this->setExpectedException('LogicException'); - - File::setDocumentRoot(__DIR__.'/Fixtures/not_here'); - } - public function testGetNameReturnsNameWithExtension() { $this->assertEquals('test.gif', $this->file->getName());