From bf48c1fc3ab6d07ae15bdbbf302bc7379de42474 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 27ed3941e..2463eb6cd 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -508,14 +508,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 = [ "$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 df30c537b..dded87dc0 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()); });