Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Further optimizations to path scanning.

  • Loading branch information...
commit 776992dc6ca3864c862beefe038d64dca289fe03 1 parent ef23ecf
@markstory markstory authored
Showing with 20 additions and 12 deletions.
  1. +20 −12 cake/libs/view/view.php
View
32 cake/libs/view/view.php
@@ -850,12 +850,16 @@ 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 ($this->ext != '.ctp' && file_exists($path . $name . '.ctp')) {
- return $path . $name . '.ctp';
+
+ $exts = array($this->ext);
+ if ($this->ext !== '.ctp') {
+ array_push($exts, '.ctp');
+ }
+ foreach ($exts as $ext) {
+ foreach ($paths as $path) {
+ if (file_exists($path . $name . $ext)) {
+ return $path . $name . $ext;
+ }
}
}
$defaultPath = $paths[0];
@@ -889,12 +893,16 @@ function _getLayoutFileName($name = null) {
}
$paths = $this->_paths(Inflector::underscore($this->plugin));
$file = 'layouts' . DS . $subDir . $name;
-
- foreach ($paths as $path) {
- if (file_exists($path . $file . $this->ext)) {
- return $path . $file . $this->ext;
- } elseif (file_exists($path . $file . '.ctp')) {
- return $path . $file . '.ctp';
+
+ $exts = array($this->ext);
+ if ($this->ext !== '.ctp') {
+ array_push($exts, '.ctp');
+ }
+ foreach ($exts as $ext) {
+ foreach ($paths as $path) {
+ if (file_exists($path . $file . $ext)) {
+ return $path . $file . $ext;
+ }
}
}
return $this->_missingView($paths[0] . $file . $this->ext, 'missingLayout');
Please sign in to comment.
Something went wrong with that request. Please try again.