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
              * @var $middleware LuAbstractMiddleware
88
              * @var $middleware LuAbstractMiddleware
89
              */
89
              */
90
             $middleware = new $middlewareName();
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
             $parameters = $middleware->onBefore($route, $parameters);
95
             $parameters = $middleware->onBefore($route, $parameters);
93
             $middlewares[] = [
96
             $middlewares[] = [
94
                 'middleware' => $middleware,
97
                 'middleware' => $middleware,
155
         foreach ($middlewares as $middlewareArray) {
158
         foreach ($middlewares as $middlewareArray) {
156
             $middleware = $middlewareArray['middleware'];
159
             $middleware = $middlewareArray['middleware'];
157
             $middlewareDbo = $middlewareArray['dbo'];
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
             $result = $middleware->onAfter($route, $parameters, $result);
165
             $result = $middleware->onAfter($route, $parameters, $result);
160
         }
166
         }
161
 
167
 

Loading…
Cancel
Save