public function LanguageSelectionPageConditionPath::evaluate in Language Selection Page 8.2
Evaluates the condition and returns TRUE or FALSE accordingly.
Return value
bool TRUE if the condition has been met, FALSE otherwise.
Overrides LanguageSelectionPageConditionBase::evaluate
File
- src/
Plugin/ LanguageSelectionPageCondition/ LanguageSelectionPageConditionPath.php, line 166
Class
- LanguageSelectionPageConditionPath
- Class for the Path condition plugin.
Namespace
Drupal\language_selection_page\Plugin\LanguageSelectionPageConditionCode
public function evaluate() {
$configuration = $this
->getConfiguration();
$configuration_lsp = $this->configFactory
->getEditable('language_selection_page.negotiation');
$system_site = $this->configFactory
->getEditable('system.site');
if ($configuration['path'] === $system_site
->get('page.front')) {
$configuration_lsp
->set('path', '/language_selection_page')
->save();
$system_site
->set('page.front', '/node')
->save();
$this->messenger
->addError($this
->t('The Language Selection Page cannot be used as frontpage. To avoid infinite redirect loops, the language selection page path has been reset to <strong>/language_selection_page</strong> and the default frontpage setting has been reset to <strong>/node</strong>.'));
return $this
->block();
}
$current_path = $this->currentPath
->getPath($this->requestStack
->getCurrentRequest());
$alias = $this->aliasManager
->getAliasByPath($current_path);
foreach ([
$current_path,
$alias,
] as $path) {
if ($path === $configuration[$this
->getPluginId()]) {
return $this
->block();
}
}
return $this
->pass();
}