You are here

class Imce in IMCE 8

Same name in this branch
  1. 8 src/Imce.php \Drupal\imce\Imce
  2. 8 src/Plugin/BUEditorPlugin/Imce.php \Drupal\imce\Plugin\BUEditorPlugin\Imce
  3. 8 src/Plugin/CKEditorPlugin/Imce.php \Drupal\imce\Plugin\CKEditorPlugin\Imce
Same name and namespace in other branches
  1. 8.2 src/Plugin/BUEditorPlugin/Imce.php \Drupal\imce\Plugin\BUEditorPlugin\Imce

Defines Imce as a BUEditor plugin.

Plugin annotation


@BUEditorPlugin(
  id = "imce",
  label = "Imce File Manager"
)

Hierarchy

  • class \Drupal\imce\Plugin\BUEditorPlugin\Imce extends \Drupal\bueditor\BUEditorPluginBase

Expanded class hierarchy of Imce

File

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

Namespace

Drupal\imce\Plugin\BUEditorPlugin
View source
class Imce extends BUEditorPluginBase {

  /**
   * {@inheritdoc}
   */

  // @codingStandardsIgnoreLine
  public function alterEditorJS(array &$js, BUEditorEditor $bueditor_editor, Editor $editor = NULL) {

    // Check selected file browser.
    if (isset($js['settings']['fileBrowser']) && $js['settings']['fileBrowser'] === 'imce') {

      // Check access.
      if (ImceMain::access()) {
        $js['libraries'][] = 'imce/drupal.imce.bueditor';
      }
      else {
        unset($js['settings']['fileBrowser']);
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  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;
    }
  }

}

Members