Skip to content
Permalink
Browse files

Simplify view path generation.

Use fewer array_merge() calls so the code should theoretically be a bit
faster.

Refs #4064
  • Loading branch information...
markstory committed Jul 25, 2014
1 parent a084fce commit 360aa14d3515076c9d735df8994b6c72e006a6a7
Showing with 5 additions and 9 deletions.
  1. +5 −9 src/View/View.php
@@ -930,29 +930,25 @@ protected function _paths($plugin = null, $cached = true) {
return $this->_pathsForPlugin[$plugin];
}
}
$paths = array();
$viewPaths = App::path('Template');
$pluginPaths = $themePaths = [];
if (!empty($plugin)) {
for ($i = 0, $count = count($viewPaths); $i < $count; $i++) {
$paths[] = $viewPaths[$i] . 'Plugin' . DS . $plugin . DS;
$pluginPaths[] = $viewPaths[$i] . 'Plugin' . DS . $plugin . DS;
}
$paths = array_merge($paths, App::path('Template', $plugin));
$pluginPaths = array_merge($pluginPaths, App::path('Template', $plugin));
}
$paths = array_unique(array_merge($paths, $viewPaths));
if (!empty($this->theme)) {
$theme = Inflector::camelize($this->theme);
$themePaths = App::path('Template', $theme);
$themePaths = App::path('Template', Inflector::camelize($this->theme));
if ($plugin) {
for ($i = 0, $count = count($viewPaths); $i < $count; $i++) {
array_unshift($themePaths, $themePaths[$i] . 'Plugin' . DS . $plugin . DS);
}
}
$paths = array_merge($themePaths, $paths);
}
$paths = array_merge($paths, App::core('Template'));
$paths = array_merge($themePaths, $pluginPaths, $viewPaths, App::core('Template'));
if ($plugin !== null) {
return $this->_pathsForPlugin[$plugin] = $paths;

0 comments on commit 360aa14

Please sign in to comment.
You can’t perform that action at this time.