function LanguageNegotiator::isNegotiationMethodEnabled

Same name in other branches
  1. 9 core/modules/language/src/LanguageNegotiator.php \Drupal\language\LanguageNegotiator::isNegotiationMethodEnabled()
  2. 10 core/modules/language/src/LanguageNegotiator.php \Drupal\language\LanguageNegotiator::isNegotiationMethodEnabled()
  3. 11.x core/modules/language/src/LanguageNegotiator.php \Drupal\language\LanguageNegotiator::isNegotiationMethodEnabled()

Overrides LanguageNegotiatorInterface::isNegotiationMethodEnabled

File

core/modules/language/src/LanguageNegotiator.php, line 230

Class

LanguageNegotiator
Class responsible for performing language negotiation.

Namespace

Drupal\language

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.