Provides a human readable summary of the condition's configuration.
Overrides ConditionInterface::summary
public function summary() {
$language_list = language_list(Lang::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->langcode])) {
$result[$item->langcode] = $item->name;
}
return $result;
}, array());
// 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 t('The language is not @languages.', array(
'@languages' => $languages,
));
}
return t('The language is @languages.', array(
'@languages' => $languages,
));
}