You are here

public function Imce::alterEditorForm in IMCE 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/BUEditorPlugin/Imce.php \Drupal\imce\Plugin\BUEditorPlugin\Imce::alterEditorForm()

File

src/Plugin/BUEditorPlugin/Imce.php, line 42

Class

Imce
Defines Imce as a BUEditor plugin.

Namespace

Drupal\imce\Plugin\BUEditorPlugin

Code

public function alterEditorForm(array &$form, FormStateInterface $form_state, BUEditorEditor $bueditor_editor) {

  // Add imce option to file browser field.
  $fb =& $form['settings']['fileBrowser'];
  $fb['#options']['imce'] = $this
    ->t('Imce File Manager');

  // Add configuration link.
  $form['settings']['imce'] = [
    '#type' => 'container',
    '#states' => [
      'visible' => [
        ':input[name="settings[fileBrowser]"]' => [
          'value' => 'imce',
        ],
      ],
    ],
    '#attributes' => [
      'class' => [
        'description',
      ],
    ],
    'content' => [
      '#markup' => $this
        ->t('Configure <a href=":url">Imce File Manager</a>.', [
        ':url' => Url::fromRoute('imce.admin')
          ->toString(),
      ]),
    ],
  ];

  // Set weight.
  if (isset($fb['#weight'])) {
    $form['settings']['imce']['#weight'] = $fb['#weight'] + 0.1;
  }
}