comparison core/modules/system/src/Plugin/Condition/RequestPath.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php 1 <?php
2 2
3 namespace Drupal\system\Plugin\Condition; 3 namespace Drupal\system\Plugin\Condition;
4 4
5 use Drupal\Component\Utility\Unicode;
6 use Drupal\Core\Condition\ConditionPluginBase; 5 use Drupal\Core\Condition\ConditionPluginBase;
7 use Drupal\Core\Form\FormStateInterface; 6 use Drupal\Core\Form\FormStateInterface;
8 use Drupal\Core\Path\AliasManagerInterface; 7 use Drupal\Core\Path\AliasManagerInterface;
9 use Drupal\Core\Path\CurrentPathStack; 8 use Drupal\Core\Path\CurrentPathStack;
10 use Drupal\Core\Path\PathMatcherInterface; 9 use Drupal\Core\Path\PathMatcherInterface;
137 * {@inheritdoc} 136 * {@inheritdoc}
138 */ 137 */
139 public function evaluate() { 138 public function evaluate() {
140 // Convert path to lowercase. This allows comparison of the same path 139 // Convert path to lowercase. This allows comparison of the same path
141 // with different case. Ex: /Page, /page, /PAGE. 140 // with different case. Ex: /Page, /page, /PAGE.
142 $pages = Unicode::strtolower($this->configuration['pages']); 141 $pages = mb_strtolower($this->configuration['pages']);
143 if (!$pages) { 142 if (!$pages) {
144 return TRUE; 143 return TRUE;
145 } 144 }
146 145
147 $request = $this->requestStack->getCurrentRequest(); 146 $request = $this->requestStack->getCurrentRequest();
148 // Compare the lowercase path alias (if any) and internal path. 147 // Compare the lowercase path alias (if any) and internal path.
149 $path = $this->currentPath->getPath($request); 148 $path = $this->currentPath->getPath($request);
150 // Do not trim a trailing slash if that is the complete path. 149 // Do not trim a trailing slash if that is the complete path.
151 $path = $path === '/' ? $path : rtrim($path, '/'); 150 $path = $path === '/' ? $path : rtrim($path, '/');
152 $path_alias = Unicode::strtolower($this->aliasManager->getAliasByPath($path)); 151 $path_alias = mb_strtolower($this->aliasManager->getAliasByPath($path));
153 152
154 return $this->pathMatcher->matchPath($path_alias, $pages) || (($path != $path_alias) && $this->pathMatcher->matchPath($path, $pages)); 153 return $this->pathMatcher->matchPath($path_alias, $pages) || (($path != $path_alias) && $this->pathMatcher->matchPath($path, $pages));
155 } 154 }
156 155
157 /** 156 /**