public function RequestMatcher::matches

@api

Overrides RequestMatcherInterface::matches

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php, line 115

Class

RequestMatcher
RequestMatcher compares a pre-defined set of checks against a Request instance.

Namespace

Symfony\Component\HttpFoundation

Code

public function matches(Request $request) {
  if (null !== $this->methods && !in_array($request
    ->getMethod(), $this->methods)) {
    return false;
  }
  foreach ($this->attributes as $key => $pattern) {
    if (!preg_match('#' . str_replace('#', '\\#', $pattern) . '#', $request->attributes
      ->get($key))) {
      return false;
    }
  }
  if (null !== $this->path) {
    $path = str_replace('#', '\\#', $this->path);
    if (!preg_match('#' . $path . '#', rawurldecode($request
      ->getPathInfo()))) {
      return false;
    }
  }
  if (null !== $this->host && !preg_match('#' . str_replace('#', '\\#', $this->host) . '#', $request
    ->getHost())) {
    return false;
  }
  if (null !== $this->ip && !$this
    ->checkIp($request
    ->getClientIp(), $this->ip)) {
    return false;
  }
  return true;
}