You are here

public function RequestPath::evaluate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Plugin/Condition/RequestPath.php \Drupal\system\Plugin\Condition\RequestPath::evaluate()

Evaluates the condition and returns TRUE or FALSE accordingly.

Return value

bool TRUE if the condition has been met, FALSE otherwise.

Overrides ConditionInterface::evaluate

File

core/modules/system/src/Plugin/Condition/RequestPath.php, line 145
Contains \Drupal\system\Plugin\Condition\RequestPath.

Class

RequestPath
Provides a 'Request Path' condition.

Namespace

Drupal\system\Plugin\Condition

Code

public function evaluate() {

  // Convert path to lowercase. This allows comparison of the same path
  // with different case. Ex: /Page, /page, /PAGE.
  $pages = Unicode::strtolower($this->configuration['pages']);
  if (!$pages) {
    return TRUE;
  }
  $request = $this->requestStack
    ->getCurrentRequest();

  // Compare the lowercase path alias (if any) and internal path.
  $path = rtrim($this->currentPath
    ->getPath($request), '/');
  $path_alias = Unicode::strtolower($this->aliasManager
    ->getAliasByPath($path));
  return $this->pathMatcher
    ->matchPath($path_alias, $pages) || $path != $path_alias && $this->pathMatcher
    ->matchPath($path, $pages);
}