Browse Source

Merge pull request #16947 from fabsn182/patch-1

4.x: Simplify template path building
Mark Story 3 years ago
parent
commit
61a809b82e
1 changed files with 10 additions and 12 deletions
  1. 10 12
      src/View/View.php

+ 10 - 12
src/View/View.php

@@ -1601,8 +1601,8 @@ class View implements EventDispatcherInterface
         $templatePaths = App::path(static::NAME_TEMPLATE);
         $pluginPaths = $themePaths = [];
         if (!empty($plugin)) {
-            for ($i = 0, $count = count($templatePaths); $i < $count; $i++) {
-                $pluginPaths[] = $templatePaths[$i]
+            foreach ($templatePaths as $templatePath) {
+                $pluginPaths[] = $templatePath
                     . static::PLUGIN_TEMPLATE_FOLDER
                     . DIRECTORY_SEPARATOR
                     . $plugin
@@ -1615,16 +1615,14 @@ class View implements EventDispatcherInterface
             $themePaths[] = Plugin::templatePath(Inflector::camelize($this->theme));
 
             if ($plugin) {
-                for ($i = 0, $count = count($themePaths); $i < $count; $i++) {
-                    array_unshift(
-                        $themePaths,
-                        $themePaths[$i]
-                            . static::PLUGIN_TEMPLATE_FOLDER
-                            . DIRECTORY_SEPARATOR
-                            . $plugin
-                            . DIRECTORY_SEPARATOR
-                    );
-                }
+                array_unshift(
+                    $themePaths,
+                    $themePaths[0]
+                        . static::PLUGIN_TEMPLATE_FOLDER
+                        . DIRECTORY_SEPARATOR
+                        . $plugin
+                        . DIRECTORY_SEPARATOR
+                );
             }
         }