public function LanguageNegotiator::isNegotiationMethodEnabled in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/language/src/LanguageNegotiator.php \Drupal\language\LanguageNegotiator::isNegotiationMethodEnabled()
Checks whether a language negotiation method is enabled for a language type.
Parameters
$method_id: The language negotiation method ID.
$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 235 - Contains \Drupal\language\LanguageNegotiator.
Class
- LanguageNegotiator
- Class responsible for performing language negotiation.
Namespace
Drupal\languageCode
public function isNegotiationMethodEnabled($method_id, $type = NULL) {
$enabled = FALSE;
$language_types = !empty($type) ? array(
$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;
}