|
@@ -22,6 +22,7 @@ class RequestMatcher implements RequestMatcherInterface
|
|
|
protected $host;
|
|
|
protected $methods;
|
|
|
protected $ip;
|
|
|
+ protected $attributes = array();
|
|
|
|
|
|
/**
|
|
|
* Adds a check for the URL host name.
|
|
@@ -63,6 +64,17 @@ class RequestMatcher implements RequestMatcherInterface
|
|
|
$this->methods = array_map(function ($m) { return strtolower($m); }, is_array($method) ? $method : array($method));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Adds a check for request attribute.
|
|
|
+ *
|
|
|
+ * @param string $key The request attribute name
|
|
|
+ * @param string $regexp A Regexp
|
|
|
+ */
|
|
|
+ public function matchAttribute($key, $regexp)
|
|
|
+ {
|
|
|
+ $this->attributes[$key] = $regexp;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* {@inheritdoc}
|
|
|
*/
|
|
@@ -72,6 +84,12 @@ class RequestMatcher implements RequestMatcherInterface
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ foreach ($this->attributes as $key => $pattern) {
|
|
|
+ if (!preg_match($pattern, $request->attributes->get($key))) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (null !== $this->path && !preg_match($this->path, $request->getPathInfo())) {
|
|
|
return false;
|
|
|
}
|