瀏覽代碼

middleware parameters injection

develop
Robin Thoni 8 年之前
父節點
當前提交
c823b773f4
共有 1 個檔案被更改,包括 8 行新增2 行删除
  1. 8
    2
      src/Utils/Controller/LuRoute.php

+ 8
- 2
src/Utils/Controller/LuRoute.php 查看文件

@@ -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…
取消
儲存