Skip to content

Commit

Permalink
Minor refactor in how paths are checked, so that fallback extensions …
Browse files Browse the repository at this point in the history
…are checked only when all paths fail, instead of for each path. Refs #49
  • Loading branch information
markstory committed Aug 30, 2009
1 parent 2dca77c commit 8be5de9
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions cake/libs/view/view.php
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 8be5de9

Please sign in to comment.