File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/Symfony/Component/HttpFoundation Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ class RequestMatcher implements RequestMatcherInterface
22
22
protected $ host ;
23
23
protected $ methods ;
24
24
protected $ ip ;
25
+ protected $ attributes = array ();
25
26
26
27
/**
27
28
* Adds a check for the URL host name.
@@ -63,6 +64,17 @@ public function matchMethod($method)
63
64
$ this ->methods = array_map (function ($ m ) { return strtolower ($ m ); }, is_array ($ method ) ? $ method : array ($ method ));
64
65
}
65
66
67
+ /**
68
+ * Adds a check for request attribute.
69
+ *
70
+ * @param string $key The request attribute name
71
+ * @param string $regexp A Regexp
72
+ */
73
+ public function matchAttribute ($ key , $ regexp )
74
+ {
75
+ $ this ->attributes [$ key ] = $ regexp ;
76
+ }
77
+
66
78
/**
67
79
* {@inheritdoc}
68
80
*/
@@ -72,6 +84,12 @@ public function matches(Request $request)
72
84
return false ;
73
85
}
74
86
87
+ foreach ($ this ->attributes as $ key => $ pattern ) {
88
+ if (!preg_match ($ pattern , $ request ->attributes ->get ($ key ))) {
89
+ return false ;
90
+ }
91
+ }
92
+
75
93
if (null !== $ this ->path && !preg_match ($ this ->path , $ request ->getPathInfo ())) {
76
94
return false ;
77
95
}
You can’t perform that action at this time.
0 commit comments