function Language::summary
Provides a human readable summary of the condition's configuration.
Overrides ConditionInterface::summary
File
- 
              core/
modules/ language/ src/ Plugin/ Condition/ Language.php, line 103  
Class
- Language
 - Provides a 'Language' condition.
 
Namespace
Drupal\language\Plugin\ConditionCode
public function summary() {
  $language_list = $this->languageManager
    ->getLanguages(LanguageInterface::STATE_ALL);
  $selected = $this->configuration['langcodes'];
  // Reduce the language list to an array of language names.
  $language_names = array_reduce($language_list, function ($result, $item) use ($selected) {
    // If the current item of the $language_list array is one of the selected
    // languages, add it to the $results array.
    if (!empty($selected[$item->getId()])) {
      $result[$item->getId()] = $item->getName();
    }
    return $result;
  }, []);
  // If we have more than one language selected, separate them by commas.
  if (count($this->configuration['langcodes']) > 1) {
    $languages = implode(', ', $language_names);
  }
  else {
    // If we have just one language just grab the only present value.
    $languages = array_pop($language_names);
  }
  if (!empty($this->configuration['negate'])) {
    return $this->t('The language is not @languages.', [
      '@languages' => $languages,
    ]);
  }
  return $this->t('The language is @languages.', [
    '@languages' => $languages,
  ]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.