Permalink
Browse files

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
  • Loading branch information...
1 parent 2dca77c commit 8be5de947bb75ea71d9685708ec7c73727be72f1 @markstory markstory committed Aug 30, 2009
Showing with 9 additions and 10 deletions.
  1. +9 −10 cake/libs/view/view.php
View
@@ -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;
}

0 comments on commit 8be5de9

Please sign in to comment.