Browse Source

middleware parameters injection

develop
Robin Thoni 8 years ago
parent
commit
c823b773f4
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      src/Utils/Controller/LuRoute.php

+ 8
- 2
src/Utils/Controller/LuRoute.php View File

@@ -88,7 +88,10 @@ class LuRoute {
88 88
              * @var $middleware LuAbstractMiddleware
89 89
              */
90 90
             $middleware = new $middlewareName();
91
-            $parameters["_middleware"] = array_merge($middlewareDbo->getParameters(), $route->getParameters());
91
+            $parameters["_middleware"] = $middlewareDbo->getParameters();
92
+            foreach ($route->getParameters() as $key => $value) {
93
+                $parameters["_middleware"][$key] = $value;
94
+            }
92 95
             $parameters = $middleware->onBefore($route, $parameters);
93 96
             $middlewares[] = [
94 97
                 'middleware' => $middleware,
@@ -155,7 +158,10 @@ class LuRoute {
155 158
         foreach ($middlewares as $middlewareArray) {
156 159
             $middleware = $middlewareArray['middleware'];
157 160
             $middlewareDbo = $middlewareArray['dbo'];
158
-            $parameters["_middleware"] = array_merge($middlewareDbo->getParameters(), $route->getParameters());
161
+            $parameters["_middleware"] = $middlewareDbo->getParameters();
162
+            foreach ($route->getParameters() as $key => $value) {
163
+                $parameters["_middleware"][$key] = $value;
164
+            }
159 165
             $result = $middleware->onAfter($route, $parameters, $result);
160 166
         }
161 167
 

Loading…
Cancel
Save