Imce.php in IMCE 8
File
src/Plugin/BUEditorPlugin/Imce.php
View source
<?php
namespace Drupal\imce\Plugin\BUEditorPlugin;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\editor\Entity\Editor;
use Drupal\bueditor\BUEditorPluginBase;
use Drupal\bueditor\Entity\BUEditorEditor;
use Drupal\imce\Imce as ImceMain;
class Imce extends BUEditorPluginBase {
public function alterEditorJS(array &$js, BUEditorEditor $bueditor_editor, Editor $editor = NULL) {
if (isset($js['settings']['fileBrowser']) && $js['settings']['fileBrowser'] === 'imce') {
if (ImceMain::access()) {
$js['libraries'][] = 'imce/drupal.imce.bueditor';
}
else {
unset($js['settings']['fileBrowser']);
}
}
}
public function alterEditorForm(array &$form, FormStateInterface $form_state, BUEditorEditor $bueditor_editor) {
$fb =& $form['settings']['fileBrowser'];
$fb['#options']['imce'] = $this
->t('Imce File Manager');
$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(),
]),
],
];
if (isset($fb['#weight'])) {
$form['settings']['imce']['#weight'] = $fb['#weight'] + 0.1;
}
}
}
Classes
Name |
Description |
Imce |
Defines Imce as a BUEditor plugin. |