function RequestPath::evaluate
Same name in other branches
- 9 core/modules/system/src/Plugin/Condition/RequestPath.php \Drupal\system\Plugin\Condition\RequestPath::evaluate()
- 10 core/modules/system/src/Plugin/Condition/RequestPath.php \Drupal\system\Plugin\Condition\RequestPath::evaluate()
- 11.x core/modules/system/src/Plugin/Condition/RequestPath.php \Drupal\system\Plugin\Condition\RequestPath::evaluate()
Overrides ConditionInterface::evaluate
File
-
core/
modules/ system/ src/ Plugin/ Condition/ RequestPath.php, line 145
Class
- RequestPath
- Provides a 'Request Path' condition.
Namespace
Drupal\system\Plugin\ConditionCode
public function evaluate() {
// Convert path to lowercase. This allows comparison of the same path
// with different case. Ex: /Page, /page, /PAGE.
$pages = mb_strtolower($this->configuration['pages']);
if (!$pages) {
return TRUE;
}
$request = $this->requestStack
->getCurrentRequest();
// Compare the lowercase path alias (if any) and internal path.
$path = $this->currentPath
->getPath($request);
// Do not trim a trailing slash if that is the complete path.
$path = $path === '/' ? $path : rtrim($path, '/');
$path_alias = mb_strtolower($this->aliasManager
->getAliasByPath($path));
return $this->pathMatcher
->matchPath($path_alias, $pages) || $path != $path_alias && $this->pathMatcher
->matchPath($path, $pages);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.