From 9276c00e26433cf25e25ff9dc22204a13c086d0c Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 22 Jul 2014 13:29:16 +0200 Subject: [PATCH] Presenter::formatLayoutTemplateFiles() when local 'template' folder exists, bypasses searching in parent folders (BC break) --- src/Application/UI/Presenter.php | 4 ++-- .../Presenter.formatLayoutTemplateFiles.phpt | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index 2c52c0659..6fc63fb18 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -504,14 +504,14 @@ public function formatLayoutTemplateFiles() $layout = $this->layout ? $this->layout : 'layout'; $rc = $this->getReflection(); $dir = dirname($rc->getFileName()); - $dir = is_dir("$dir/templates") ? $dir : dirname($dir); + $dir = ($newWay = is_dir("$dir/templates")) ? $dir : dirname($dir); $list = array( "$dir/templates/$presenter/@$layout.latte", "$dir/templates/$presenter.@$layout.latte", ); do { $list[] = "$dir/templates/@$layout.latte"; - $dir = dirname($dir); + $dir = $newWay ? FALSE : dirname($dir); } while ($dir && ($name = substr($name, 0, strrpos($name, ':')))); while (($rc = $rc->getParentClass()) && $rc->getName() !== __CLASS__) { diff --git a/tests/Application.templates/Presenter.formatLayoutTemplateFiles.phpt b/tests/Application.templates/Presenter.formatLayoutTemplateFiles.phpt index 35db2bed5..e076d676f 100644 --- a/tests/Application.templates/Presenter.formatLayoutTemplateFiles.phpt +++ b/tests/Application.templates/Presenter.formatLayoutTemplateFiles.phpt @@ -47,8 +47,6 @@ test(function() { // with module & subdir templates __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One/@layout.latte', __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One.@layout.latte', __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/@layout.latte', - __DIR__ . '/templates/@layout.latte', - dirname(__DIR__) . '/templates/@layout.latte', ), $presenter->formatLayoutTemplateFiles() ); });