You are here

public function Bgimage::validateFileUploadSettings in CkEditor Background Image 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/CKEditorPlugin/Bgimage.php \Drupal\ckeditor_bgimage\Plugin\CKEditorPlugin\Bgimage::validateFileUploadSettings()

Element_validate handler for the "file_upload" element in settingsForm().

Moves the text editor's file upload settings from the bgimage plugin's own settings into $editor->file_upload.

See also

\Drupal\editor\Form\EditorFileDialog

ckeditor_bgimage_upload_settings_form()

File

src/Plugin/CKEditorPlugin/Bgimage.php, line 84

Class

Bgimage
Defines the "bgimage" plugin.

Namespace

Drupal\ckeditor_bgimage\Plugin\CKEditorPlugin

Code

public function validateFileUploadSettings(array $element, FormStateInterface $form_state) {
  $settings =& $form_state
    ->getValue([
    'editor',
    'settings',
    'plugins',
    'bgimage',
    'file_upload',
  ]);
  $editor = $form_state
    ->get('editor');
  foreach ($settings as $key => $value) {
    if (!empty($value)) {
      $editor
        ->setThirdPartySetting('ckeditor_bgimage', $key, $value);
    }
    else {
      $editor
        ->unsetThirdPartySetting('ckeditor_bgimage', $key);
    }
  }
  $form_state
    ->unsetValue([
    'editor',
    'settings',
    'plugins',
    'bgimage',
  ]);
}