public function RequestMatcher::matches in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-foundation/RequestMatcher.php \Symfony\Component\HttpFoundation\RequestMatcher::matches()
Decides whether the rule(s) implemented by the strategy matches the supplied request.
Parameters
Request $request The request to check for a match:
Return value
bool true if the request matches, false otherwise
Overrides RequestMatcherInterface::matches
1 call to RequestMatcher::matches()
- ExpressionRequestMatcher::matches in vendor/
symfony/ http-foundation/ ExpressionRequestMatcher.php - Decides whether the rule(s) implemented by the strategy matches the supplied request.
1 method overrides RequestMatcher::matches()
- ExpressionRequestMatcher::matches in vendor/
symfony/ http-foundation/ ExpressionRequestMatcher.php - Decides whether the rule(s) implemented by the strategy matches the supplied request.
File
- vendor/
symfony/ http-foundation/ RequestMatcher.php, line 146
Class
- RequestMatcher
- RequestMatcher compares a pre-defined set of checks against a Request instance.
Namespace
Symfony\Component\HttpFoundationCode
public function matches(Request $request) {
if ($this->schemes && !in_array($request
->getScheme(), $this->schemes)) {
return false;
}
if ($this->methods && !in_array($request
->getMethod(), $this->methods)) {
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 . '}', rawurldecode($request
->getPathInfo()))) {
return false;
}
if (null !== $this->host && !preg_match('{' . $this->host . '}i', $request
->getHost())) {
return false;
}
if (IpUtils::checkIp($request
->getClientIp(), $this->ips)) {
return true;
}
// Note to future implementors: add additional checks above the
// foreach above or else your check might not be run!
return count($this->ips) === 0;
}