Browse Source

Moving viewPath setting code to setRequest()

This logic is dependet on setting the request object, so it is better placed
there.
Jose Lorenzo Rodriguez 11 years ago
parent
commit
2a4b5ae06e
1 changed files with 12 additions and 12 deletions
  1. 12 12
      src/Controller/Controller.php

+ 12 - 12
src/Controller/Controller.php

@@ -258,18 +258,6 @@ class Controller implements EventListenerInterface
             $this->name = $name;
         }
 
-        if (!$this->viewPath) {
-            $viewPath = $this->name;
-            if (isset($request->params['prefix'])) {
-                $prefixes = array_map(
-                    'Cake\Utility\Inflector::camelize',
-                    explode('/', $request->params['prefix'])
-                );
-                $viewPath = implode(DS, $prefixes) . DS . $viewPath;
-            }
-            $this->viewPath = $viewPath;
-        }
-
         if (!($request instanceof Request)) {
             $request = new Request();
         }
@@ -384,6 +372,18 @@ class Controller implements EventListenerInterface
         if (isset($request->params['pass'])) {
             $this->passedArgs = $request->params['pass'];
         }
+
+        if (!$this->viewPath) {
+            $viewPath = $this->name;
+            if (isset($request->params['prefix'])) {
+                $prefixes = array_map(
+                    'Cake\Utility\Inflector::camelize',
+                    explode('/', $request->params['prefix'])
+                );
+                $viewPath = implode(DS, $prefixes) . DS . $viewPath;
+            }
+            $this->viewPath = $viewPath;
+        }
     }
 
     /**