Symfony\Component\HttpFoundation\RequestMatcher::matches PHP Method

matches() public method

public matches ( Request $request )
$request Request
    public function matches(Request $request)
    {
        if (null !== $this->methods && !in_array(strtolower($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.'$#', $request->getPathInfo())) {
            return false;
        }

        if (null !== $this->host && !preg_match('#^'.$this->host.'$#', $request->getHost())) {
            return false;
        }

        if (null !== $this->ip && !$this->checkIp($request->getClientIp())) {
            return false;
        }

        return true;
    }

Usage Example

 public function matches(Request $request)
 {
     if (!$this->language) {
         throw new \LogicException('Unable to match the request as the expression language is not available.');
     }
     return $this->language->evaluate($this->expression, array('request' => $request, 'method' => $request->getMethod(), 'path' => rawurldecode($request->getPathInfo()), 'host' => $request->getHost(), 'ip' => $request->getClientIp(), 'attributes' => $request->attributes->all())) && parent::matches($request);
 }
All Usage Examples Of Symfony\Component\HttpFoundation\RequestMatcher::matches