public function LanguageNegotiator::isNegotiationMethodEnabled in Drupal 9
Same name and namespace in other branches
- 8 core/modules/language/src/LanguageNegotiator.php \Drupal\language\LanguageNegotiator::isNegotiationMethodEnabled()
Checks whether a language negotiation method is enabled for a language type.
Parameters
string $method_id: The language negotiation method ID.
string $type: (optional) The language type. If none is passed, all the configurable language types will be inspected.
Return value
bool TRUE if the method is enabled for at least one of the given language types, or FALSE otherwise.
Overrides LanguageNegotiatorInterface::isNegotiationMethodEnabled
File
- core/
modules/ language/ src/ LanguageNegotiator.php, line 232
Class
- LanguageNegotiator
- Class responsible for performing language negotiation.
Namespace
Drupal\languageCode
public function isNegotiationMethodEnabled($method_id, $type = NULL) {
$enabled = FALSE;
$language_types = !empty($type) ? [
$type,
] : $this->languageManager
->getLanguageTypes();
foreach ($language_types as $type) {
$enabled_methods = $this
->getEnabledNegotiators($type);
if (isset($enabled_methods[$method_id])) {
$enabled = TRUE;
break;
}
}
return $enabled;
}