abstract class N1EDEcosystemCKEditorPlugin in N1ED - Visual editor as CKEditor plugin with Bootstrap support 8
Defines plugin.
Plugin annotation
@CKEditorPlugin(
id = "N1ED",
label = @Translation("N1ED"),
module = "n1ed"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\ckeditor\CKEditorPluginBase implements CKEditorPluginButtonsInterface, CKEditorPluginInterface
- class \Drupal\n1ed\Plugin\N1EDEcosystemCKEditorPlugin implements CKEditorPluginConfigurableInterface, CKEditorPluginContextualInterface
- class \Drupal\ckeditor\CKEditorPluginBase implements CKEditorPluginButtonsInterface, CKEditorPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of N1EDEcosystemCKEditorPlugin
1 file declares its use of N1EDEcosystemCKEditorPlugin
File
- src/
Plugin/ N1EDEcosystemCKEditorPlugin.php, line 21
Namespace
Drupal\n1ed\PluginView source
abstract class N1EDEcosystemCKEditorPlugin extends CKEditorPluginBase implements CKEditorPluginConfigurableInterface, CKEditorPluginContextualInterface {
/**
* Returns plugin name.
*
* @return string
* Plugin name is a name of add-on in CKEditor terms
*/
public abstract function getPluginName();
/**
* Returns module name.
*
* @return string
* Module name is a name of module in Drupal terms
*/
public abstract function getModuleName();
/**
* Returns buttons list.
*
* @return array
* Associative array like in @CKEditorPlugin->getButtons
*/
public abstract function getButtonsDef();
/**
* Adds controls to form using this class methods.
*/
public abstract function addControlsToForm(&$form, $editor, $config);
/**
* {@inheritdoc}
*/
public function getButtons() {
if (!$this
->isInstalled()) {
return array();
}
return $this
->getButtonsDef();
}
/**
* {@inheritdoc}
*/
public function getFile() {
return '/libraries/' . $this
->getPluginName() . '/plugin.min.js';
}
/**
* {@inheritdoc}
*/
public function getDependencies(Editor $editor) {
return array();
}
/**
* {@inheritdoc}
*/
public function getLibraries(Editor $editor) {
return array();
}
/**
* {@inheritdoc}
*/
public function isInternal() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function isEnabled(Editor $editor) {
return TRUE;
}
protected function getConfigParam($settings, $name, $default, $type) {
if (isset($settings[$name]) && is_string($settings[$name]) && strlen($settings[$name]) > 0) {
$value = $settings[$name];
}
else {
$value = $default;
}
if (isset($type) && $type == 'number') {
$value = intval($value);
}
else {
if (isset($type) && $type == 'boolean') {
if ($value == 'true') {
$value = true;
}
else {
if ($value == 'false') {
$value = false;
}
}
}
else {
if (isset($type) && $type == 'json') {
if ($value != '') {
$value = json_decode($value);
}
}
}
}
$drupal8_specific_defaults = array(
'urlFileManager' => '/flmngr',
'urlFiles' => '/sites/default/files/flmngr',
'dirUploads' => '/uploads/',
);
if (isset($drupal8_specific_defaults[$name]) && $value == '') {
$value = $drupal8_specific_defaults[$name];
}
return $value;
}
/**
* {@inheritdoc}
*/
public function getConfig(Editor $editor) {
$settings = array();
if (isset($editor
->getSettings()['plugins'][$this
->getPluginName()])) {
$settings = $editor
->getSettings()['plugins'][$this
->getPluginName()];
}
return $settings;
}
protected function addStringToForm(&$form, $settings, $param, $default) {
$form[$param] = array(
'#type' => 'textfield',
'#title' => $param,
'#title_display' => 'invisible',
'#default_value' => $this
->getConfigParam($settings, $param, $default, 'string'),
'#attributes' => array(
'style' => 'display: none!important',
'data-n1ed-eco-param-name' => $param,
'data-n1ed-eco-param-type' => 'string',
'data-n1ed-eco-param-default' => $default,
),
);
}
protected function addNumberToForm(&$form, $settings, $param, $default) {
$form[$param] = array(
'#type' => 'textfield',
'#title' => $param,
'#title_display' => 'invisible',
'#default_value' => $this
->getConfigParam($settings, $param, $default, 'number'),
'#attributes' => array(
'style' => 'display: none!important',
'data-n1ed-eco-param-name' => $param,
'data-n1ed-eco-param-type' => 'number',
'data-n1ed-eco-param-default' => $default,
),
);
}
protected function addBooleanToForm(&$form, $settings, $param, $default) {
$form[$param] = array(
'#type' => 'textfield',
'#title' => $param,
'#title_display' => 'invisible',
'#default_value' => $this
->getConfigParam($settings, $param, $default, 'boolean') ? "true" : "false",
'#attributes' => array(
'style' => 'display: none!important',
'data-n1ed-eco-param-name' => $param,
'data-n1ed-eco-param-type' => 'boolean',
'data-n1ed-eco-param-default' => $default ? "true" : "false",
),
);
}
protected function addJsonToForm(&$form, $settings, $param, $default) {
$form[$param] = array(
'#type' => 'textarea',
'#title' => $param,
'#title_display' => 'invisible',
'#default_value' => $this
->getConfigParam($settings, $param, $default, 'string'),
'#attributes' => array(
'style' => 'display: none!important',
'data-n1ed-eco-param-name' => $param,
'data-n1ed-eco-param-type' => 'json',
'data-n1ed-eco-param-default' => $default,
),
);
}
protected function isInstalled() {
return file_exists($_SERVER['DOCUMENT_ROOT'] . '/libraries/' . $this
->getPluginName());
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
$config = $this
->getConfig($editor);
$form['info'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#attributes' => [
'data-n1ed-eco-plugin' => $this
->getPluginName(),
'data-plugin-installed' => $this
->isInstalled() ? "true" : "false",
'style' => 'display: inline-block;margin-top: 13px;margin-left: 10px;',
],
'#value' => '<a href="#n1ed-conf">Configure ' . $this
->getPluginName() . ' add-on</a>',
];
$form['#attached']['library'][] = $this
->getModuleName() . '/' . $this
->getModuleName();
$this
->addControlsToForm($form, $editor, $config);
return $form;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
N1EDEcosystemCKEditorPlugin:: |
protected | function | ||
N1EDEcosystemCKEditorPlugin:: |
abstract public | function | Adds controls to form using this class methods. | 1 |
N1EDEcosystemCKEditorPlugin:: |
protected | function | ||
N1EDEcosystemCKEditorPlugin:: |
protected | function | ||
N1EDEcosystemCKEditorPlugin:: |
protected | function | ||
N1EDEcosystemCKEditorPlugin:: |
public | function |
Returns the buttons that this plugin provides, along with metadata. Overrides CKEditorPluginButtonsInterface:: |
|
N1EDEcosystemCKEditorPlugin:: |
abstract public | function | Returns buttons list. | 1 |
N1EDEcosystemCKEditorPlugin:: |
public | function |
Returns the additions to CKEDITOR.config for a specific CKEditor instance. Overrides CKEditorPluginInterface:: |
|
N1EDEcosystemCKEditorPlugin:: |
protected | function | ||
N1EDEcosystemCKEditorPlugin:: |
public | function |
Returns a list of plugins this plugin requires. Overrides CKEditorPluginBase:: |
|
N1EDEcosystemCKEditorPlugin:: |
public | function |
Returns the Drupal root-relative file path to the plugin JavaScript file. Overrides CKEditorPluginInterface:: |
|
N1EDEcosystemCKEditorPlugin:: |
public | function |
Returns a list of libraries this plugin requires. Overrides CKEditorPluginBase:: |
|
N1EDEcosystemCKEditorPlugin:: |
abstract public | function | Returns module name. | 1 |
N1EDEcosystemCKEditorPlugin:: |
abstract public | function | Returns plugin name. | 1 |
N1EDEcosystemCKEditorPlugin:: |
public | function |
Checks if this plugin should be enabled based on the editor configuration. Overrides CKEditorPluginContextualInterface:: |
|
N1EDEcosystemCKEditorPlugin:: |
protected | function | ||
N1EDEcosystemCKEditorPlugin:: |
public | function |
Indicates if this plugin is part of the optimized CKEditor build. Overrides CKEditorPluginBase:: |
|
N1EDEcosystemCKEditorPlugin:: |
public | function |
Returns a settings form to configure this CKEditor plugin. Overrides CKEditorPluginConfigurableInterface:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |