Determines which plug-ins are enabled.
For CKEditor plugins that implement:
Internal plugins (those that are part of the bundled build of CKEditor) are excluded by default, since they are loaded implicitly. If you need to know even implicitly loaded (i.e. internal) plugins, then set the optional second parameter.
\Drupal\editor\Plugin\Core\Entity\Editor $editor: A configured text editor object.
bool $include_internal_plugins: Defaults to FALSE. When set to TRUE, plugins whose isInternal() method returns TRUE will also be included.
array A list of the enabled CKEditor plugins, with the plugin IDs as keys and the Drupal root-relative plugin files as values. For internal plugins, the value is NULL.
public function getEnabledPlugins(Editor $editor, $include_internal_plugins = FALSE) {
$plugins = array_keys($this
->getDefinitions());
$toolbar_buttons = array_unique(NestedArray::mergeDeepArray($editor->settings['toolbar']['buttons']));
$enabled_plugins = array();
foreach ($plugins as $plugin_id) {
$plugin = $this
->createInstance($plugin_id);
if (!$include_internal_plugins && $plugin
->isInternal()) {
continue;
}
$enabled = FALSE;
if ($plugin instanceof CKEditorPluginButtonsInterface) {
$plugin_buttons = array_keys($plugin
->getButtons());
$enabled = count(array_intersect($toolbar_buttons, $plugin_buttons)) > 0;
}
if (!$enabled && $plugin instanceof CKEditorPluginContextualInterface) {
$enabled = $plugin
->isEnabled($editor);
}
if ($enabled) {
$enabled_plugins[$plugin_id] = $plugin
->isInternal() ? NULL : $plugin
->getFile();
}
}
// Always return plugins in the same order.
asort($enabled_plugins);
return $enabled_plugins;
}