Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 8be5de947bb75ea71d9685708ec7c73727be72f1 1 parent 2dca77c
@markstory markstory authored
Showing with 9 additions and 10 deletions.
  1. +9 −10 cake/libs/view/view.php
View
19 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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.