You are here

public function UriCondition::isMatched in Access Filter 8

Checks the current access is matched to the condition.

Parameters

\Symfony\Component\HttpFoundation\Request $request: A request instance.

Return value

bool Boolean TRUE if condition is matched or FALSE otherwise.

Overrides ConditionInterface::isMatched

File

src/Plugin/AccessFilter/Condition/UriCondition.php, line 45

Class

UriCondition
Filter condition using request URI.

Namespace

Drupal\access_filter\Plugin\AccessFilter\Condition

Code

public function isMatched(Request $request) {
  $uri = $request
    ->getPathInfo();
  $qs = $request
    ->getQueryString();
  if ($qs !== NULL) {
    $uri .= '?' . $qs;
  }
  if (empty($this->configuration['regex'])) {
    return $uri == $this->configuration['uri'];
  }
  else {
    return (bool) preg_match($this->configuration['uri'], $uri);
  }
}