diff --git a/src/Symfony/Components/Templating/Loader/CacheLoader.php b/src/Symfony/Components/Templating/Loader/CacheLoader.php index 1599aa53931b..e8bcca7bafbf 100644 --- a/src/Symfony/Components/Templating/Loader/CacheLoader.php +++ b/src/Symfony/Components/Templating/Loader/CacheLoader.php @@ -61,10 +61,6 @@ public function load($template, array $options = array()) $file = substr($tmp, 2); $path = $dir.DIRECTORY_SEPARATOR.$file; - if ($this->loader instanceof CompilableLoaderInterface) { - $options['renderer'] = 'php'; - } - if (file_exists($path)) { if (null !== $this->debugger) { $this->debugger->log(sprintf('Fetching template "%s" from cache', $template)); @@ -79,10 +75,6 @@ public function load($template, array $options = array()) $content = $storage->getContent(); - if ($this->loader instanceof CompilableLoaderInterface) { - $content = $this->loader->compile($content); - } - if (!file_exists($dir)) { mkdir($dir, 0777, true); } diff --git a/src/Symfony/Components/Templating/Loader/CompilableLoaderInterface.php b/src/Symfony/Components/Templating/Loader/CompilableLoaderInterface.php deleted file mode 100644 index 5cb5fc9a14bb..000000000000 --- a/src/Symfony/Components/Templating/Loader/CompilableLoaderInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * CompilableLoaderInterface is the interface a template loader must implement - * if the templates are compilable. - * - * @package Symfony - * @subpackage Components_Templating - * @author Fabien Potencier - */ -interface CompilableLoaderInterface -{ - /** - * Compiles a template. - * - * @param string $template The template to compile - * - * @return string The compiled template - * - * @throws \Exception if the template is not compilable - */ - public function compile($template); -} diff --git a/tests/Symfony/Tests/Components/Templating/EngineTest.php b/tests/Symfony/Tests/Components/Templating/EngineTest.php index 15f4c19edb2e..a6b3751da015 100644 --- a/tests/Symfony/Tests/Components/Templating/EngineTest.php +++ b/tests/Symfony/Tests/Components/Templating/EngineTest.php @@ -15,7 +15,6 @@ use Symfony\Components\Templating\Engine; use Symfony\Components\Templating\Loader\Loader; -use Symfony\Components\Templating\Loader\CompilableLoaderInterface; use Symfony\Components\Templating\Renderer\Renderer; use Symfony\Components\Templating\Renderer\PhpRenderer; use Symfony\Components\Templating\Storage\Storage; @@ -115,10 +114,6 @@ public function testExtendRender() self::$loader->setTemplate('foo.php', 'extend("layout"); echo $foo ?>'); self::$loader->setTemplate('layout.php', 'render("bar") ?>-slots->get("_content") ?>-'); $this->assertEquals('bar-foo-', $engine->render('foo', array('foo' => 'foo', 'bar' => 'bar')), '->render() supports render() calls in templates'); - - // compilable templates - $engine = new ProjectTemplateEngine(new CompilableTemplateLoader(), array('foo' => new FooTemplateRenderer())); - $this->assertEquals('foo', $engine->render('index'), '->load() takes into account the renderer embedded in the Storage instance if not null'); } public function testEscape() @@ -176,18 +171,10 @@ public function load($template, array $options = array()) return false; } -} - -class CompilableTemplateLoader extends Loader implements CompilableLoaderInterface -{ - public function load($template, array $options = array()) - { - return new StringStorage($template, 'foo'); - } - public function compile($template) + public function isFresh($template, array $options = array(), $time) { - return 'COMPILED'; + return false; } } diff --git a/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php index f553ba11dc56..8db69003de49 100644 --- a/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php +++ b/tests/Symfony/Tests/Components/Templating/Loader/CacheLoaderTest.php @@ -15,7 +15,6 @@ use Symfony\Components\Templating\Loader\Loader; use Symfony\Components\Templating\Loader\CacheLoader; -use Symfony\Components\Templating\Loader\CompilableLoaderInterface; use Symfony\Components\Templating\Storage\StringStorage; class CacheLoaderTest extends \PHPUnit_Framework_TestCase @@ -39,20 +38,6 @@ public function testLoad() $this->assertTrue($debugger->hasMessage('Storing template'), '->load() logs a "Storing template" message if the template is found'); $loader->load('index'); $this->assertTrue($debugger->hasMessage('Fetching template'), '->load() logs a "Storing template" message if the template is fetched from cache'); - - // load() template compilation - $dir = sys_get_temp_dir().DIRECTORY_SEPARATOR.rand(111111, 999999); - mkdir($dir, 0777, true); - - $loader = new ProjectTemplateLoader(new CompilableTemplateLoader(), $dir); - $loader->setDebugger($debugger = new \ProjectTemplateDebugger()); - $template = $loader->load('special', array('renderer' => 'comp')); - $this->assertTrue($debugger->hasMessage('Storing template'), '->load() logs a "Storing template" message if the template is found'); - $this->assertEquals('php', $template->getRenderer(), '->load() changes the renderer to php if the template is compilable'); - - $template = $loader->load('special', array('renderer' => 'comp')); - $this->assertTrue($debugger->hasMessage('Fetching template'), '->load() logs a "Storing template" message if the template is fetched from cache'); - $this->assertEquals('php', $template->getRenderer(), '->load() changes the renderer to php if the template is compilable'); } } @@ -89,12 +74,9 @@ public function load($template, array $options = array()) return false; } -} -class CompilableTemplateLoader extends ProjectTemplateLoaderVar implements CompilableLoaderInterface -{ - public function compile($template) + public function isFresh($template, array $options = array(), $time) { - return preg_replace('/{{\s*([a-zA-Z0-9_]+)\s*}}/', '', $template); + return false; } } diff --git a/tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php b/tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php index 7bff3efd6ae9..33761fb077ef 100644 --- a/tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php +++ b/tests/Symfony/Tests/Components/Templating/Loader/LoaderTest.php @@ -35,4 +35,9 @@ public function getDebugger() { return $this->debugger; } + + public function isFresh($template, array $options = array(), $time) + { + return false; + } }