function StylesCombo::validateStylesValue

Same name in other branches
  1. 8.9.x core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php \Drupal\ckeditor\Plugin\CKEditorPlugin\StylesCombo::validateStylesValue()

#element_validate handler for the "styles" element in settingsForm().

File

core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php, line 98

Class

StylesCombo
Defines the "stylescombo" plugin.

Namespace

Drupal\ckeditor\Plugin\CKEditorPlugin

Code

public function validateStylesValue(array $element, FormStateInterface $form_state) {
    $styles_setting = $this->generateStylesSetSetting($element['#value']);
    if ($styles_setting === FALSE) {
        $form_state->setError($element, $this->t('The provided list of styles is syntactically incorrect.'));
    }
    else {
        $style_names = array_map(function ($style) {
            return $style['name'];
        }, $styles_setting);
        if (count($style_names) !== count(array_unique($style_names))) {
            $form_state->setError($element, $this->t('Each style must have a unique label.'));
        }
    }
}

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