LanguageNegotiator::isNegotiationMethodEnabled

public LanguageNegotiator::isNegotiationMethodEnabled($method_id, $type = NULL)

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 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) ? 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;
}
doc_Drupal
2016-10-29 09:22:52
Comments
Leave a Comment

Please login to continue.