diff --git a/core/modules/language/lib/Drupal/language/Plugin/Core/Condition/Language.php b/core/modules/language/lib/Drupal/language/Plugin/Core/Condition/Language.php index 7297393..70ec6ef 100644 --- a/core/modules/language/lib/Drupal/language/Plugin/Core/Condition/Language.php +++ b/core/modules/language/lib/Drupal/language/Plugin/Core/Condition/Language.php @@ -28,7 +28,7 @@ class Language extends ConditionPluginBase { /** - * Overrides \Drupal\Core\Condition\ConditionPluginBase::buildForm(). + * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { $form = parent::buildForm($form, $form_state); @@ -59,7 +59,7 @@ public function buildForm(array $form, array &$form_state) { } /** - * Overrides \Drupal\Core\Condition\ConditionPluginBase::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $this->configuration['langcodes'] = array_filter($form_state['values']['langcodes']); @@ -67,23 +67,27 @@ public function submitForm(array &$form, array &$form_state) { } /** - * Implements \Drupal\Core\Executable\ExecutableInterface::summary(). + * {@inheritdoc} */ public function summary() { $language_list = language_list(LANGUAGE_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'])) { @@ -93,15 +97,13 @@ public function summary() { } /** - * Implements \Drupal\condition\ConditionInterface::evaluate(). + * {@inheritdoc} */ public function evaluate() { $language = $this->getContextValue('language'); // Language visibility settings. if (!empty($this->configuration['langcodes'])) { - if (empty($this->configuration['langcodes'][$language->langcode])) { - return FALSE; - } + return !empty($this->configuration['langcodes'][$language->langcode]); } return TRUE; }