@@ -10,26 +10,26 @@ abstract class RouterEntry {
10
10
const REQUEST_TYPE_POST = 'post ' ;
11
11
const REQUEST_TYPE_GET = 'get ' ;
12
12
const REQUEST_TYPE_PUT = 'put ' ;
13
+ const REQUEST_TYPE_PATCH = 'patch ' ;
13
14
const REQUEST_TYPE_DELETE = 'delete ' ;
14
15
15
16
public static $ allowedRequestTypes = array (
16
17
self ::REQUEST_TYPE_DELETE ,
17
18
self ::REQUEST_TYPE_GET ,
18
19
self ::REQUEST_TYPE_POST ,
19
- self ::REQUEST_TYPE_PUT
20
+ self ::REQUEST_TYPE_PUT ,
21
+ self ::REQUEST_TYPE_PATCH
20
22
);
21
23
22
24
protected $ settings ;
23
25
protected $ callback ;
24
26
protected $ parameters ;
25
- protected $ parametersRegex ;
26
- protected $ regexMatch ;
27
27
28
28
public function __construct () {
29
29
$ this ->settings = array ();
30
30
$ this ->settings ['requestMethods ' ] = array ();
31
+ $ this ->settings ['parametersRegex ' ] = array ();
31
32
$ this ->parameters = array ();
32
- $ this ->parametersRegex = array ();
33
33
}
34
34
35
35
/**
@@ -245,13 +245,25 @@ protected function loadClass($name) {
245
245
246
246
public function loadMiddleware (Request $ request ) {
247
247
if ($ this ->getMiddleware ()) {
248
- $ middleware = $ this ->loadClass ($ this ->getMiddleware ());
249
- if (!($ middleware instanceof IMiddleware)) {
250
- throw new RouterException ($ this ->getMiddleware () . ' must be instance of Middleware ' );
248
+ if (is_array ($ this ->getMiddleware ())) {
249
+ foreach ($ this ->getMiddleware () as $ middleware ) {
250
+ $ middleware = $ this ->loadClass ($ middleware );
251
+ if (!($ middleware instanceof IMiddleware)) {
252
+ throw new RouterException ($ middleware . ' must be instance of Middleware ' );
253
+ }
254
+
255
+ /* @var $class Middleware */
256
+ $ middleware ->handle ($ request );
257
+ }
258
+ } else {
259
+ $ middleware = $ this ->loadClass ($ this ->getMiddleware ());
260
+ if (!($ middleware instanceof IMiddleware)) {
261
+ throw new RouterException ($ this ->getMiddleware () . ' must be instance of Middleware ' );
262
+ }
263
+
264
+ /* @var $class Middleware */
265
+ $ middleware ->handle ($ request );
251
266
}
252
-
253
- /* @var $class Middleware */
254
- $ middleware ->handle ($ request );
255
267
}
256
268
}
257
269
0 commit comments