|
|
@@ -964,17 +964,7 @@ class View
|
|
|
}
|
|
|
list($plugin, $name) = $this->pluginSplit($name);
|
|
|
|
|
|
- $layoutPaths = ['Layout' . DS . $subDir];
|
|
|
- if (!empty($this->request->params['prefix'])) {
|
|
|
- $prefixPath = array_map(
|
|
|
- 'Cake\Utility\Inflector::camelize',
|
|
|
- explode('/', $this->request->params['prefix'])
|
|
|
- );
|
|
|
- array_unshift(
|
|
|
- $layoutPaths,
|
|
|
- implode('/', $prefixPath) . DS . $layoutPaths[0]
|
|
|
- );
|
|
|
- }
|
|
|
+ $layoutPaths = $this->_getSubPaths('Layout' . DS . $subDir);
|
|
|
|
|
|
foreach ($this->_paths($plugin) as $path) {
|
|
|
foreach ($layoutPaths as $layoutPath) {
|
|
|
@@ -1000,15 +990,46 @@ class View
|
|
|
list($plugin, $name) = $this->pluginSplit($name);
|
|
|
|
|
|
$paths = $this->_paths($plugin);
|
|
|
+ $elementPaths = $this->_getSubPaths('Element');
|
|
|
+
|
|
|
foreach ($paths as $path) {
|
|
|
- if (file_exists($path . 'Element' . DS . $name . $this->_ext)) {
|
|
|
- return $path . 'Element' . DS . $name . $this->_ext;
|
|
|
+ foreach ($elementPaths as $elementPath) {
|
|
|
+ if (file_exists($path . $elementPath . DS . $name . $this->_ext)) {
|
|
|
+ return $path . $elementPath . DS . $name . $this->_ext;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Find all sub templates path, based on $basePath
|
|
|
+ * If a prefix is defined in the current request, this method will prepend
|
|
|
+ * the prefixed template path to the $basePath.
|
|
|
+ * This is essentially used to find prefixed template paths for elements
|
|
|
+ * and layouts.
|
|
|
+ *
|
|
|
+ * @param string $basePath Base path on which to get the prefixed one.
|
|
|
+ * @return array Array with all the templates paths.
|
|
|
+ */
|
|
|
+ protected function _getSubPaths($basePath)
|
|
|
+ {
|
|
|
+ $paths = [$basePath];
|
|
|
+ if (!empty($this->request->params['prefix'])) {
|
|
|
+ $prefixPath = array_map(
|
|
|
+ 'Cake\Utility\Inflector::camelize',
|
|
|
+ explode('/', $this->request->params['prefix'])
|
|
|
+ );
|
|
|
+ array_unshift(
|
|
|
+ $paths,
|
|
|
+ implode('/', $prefixPath) . DS . $basePath
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ return $paths;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Return all possible paths to find view files in order
|
|
|
*
|
|
|
* @param string|null $plugin Optional plugin name to scan for view files.
|