From 8be5de947bb75ea71d9685708ec7c73727be72f1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 30 Aug 2009 19:07:36 -0400 Subject: [PATCH] Minor refactor in how paths are checked, so that fallback extensions are checked only when all paths fail, instead of for each path. Refs #49 --- cake/libs/view/view.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 96aac913e72..1ed8c01cb8f 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -805,14 +805,13 @@ function _getViewFileName($name = null) { } $paths = $this->_paths(Inflector::underscore($this->plugin)); - - foreach ($paths as $path) { - if (file_exists($path . $name . $this->ext)) { - return $path . $name . $this->ext; - } elseif (file_exists($path . $name . '.ctp')) { - return $path . $name . '.ctp'; - } elseif (file_exists($path . $name . '.thtml')) { - return $path . $name . '.thtml'; + + $exts = array($this->ext, '.ctp', '.thtml'); + foreach ($exts as $ext) { + foreach ($paths as $path) { + if (file_exists($path . $name . $ext)) { + return $path . $name . $ext; + } } } $defaultPath = $paths[0]; @@ -848,8 +847,8 @@ function _getLayoutFileName($name = null) { $file = 'layouts' . DS . $subDir . $name; $exts = array($this->ext, '.ctp', '.thtml'); - foreach ($paths as $path) { - foreach ($exts as $ext) { + foreach ($exts as $ext) { + foreach ($paths as $path) { if (file_exists($path . $file . $ext)) { return $path . $file . $ext; }