CodeSnippetGeshiCKEditorButton.php in GeSHi Filter for syntax highlighting 8
File
codesnippetgeshi/src/Plugin/CKEditorPlugin/CodeSnippetGeshiCKEditorButton.php
View source
<?php
namespace Drupal\codesnippetgeshi\Plugin\CKEditorPlugin;
use Drupal\ckeditor\CKEditorPluginBase;
use Drupal\editor\Entity\Editor;
use Drupal\geshifilter\GeshiFilter;
class CodeSnippetGeshiCKEditorButton extends CKEditorPluginBase {
public function getButtons() {
return [
'CodeSnippet' => [
'label' => t('Add a button to use codesnippetgeshi plugin.'),
'image' => drupal_get_path('module', 'codesnippetgeshi') . '/icons/codesnippet.png',
],
];
}
public function getFile() {
return 'libraries/codesnippetgeshi/plugin.js';
}
public function isInternal() {
return FALSE;
}
public function getDependencies(Editor $editor) {
return [
'xml',
'ajax',
'codesnippet',
];
}
public function getLibraries(Editor $editor) {
return [];
}
public function getConfig(Editor $editor) {
$languages = GeshiFilter::getEnabledLanguages();
$languages = array_map(function ($language) {
return ucwords($language);
}, $languages);
asort($languages);
return [
'codeSnippet_languages' => $languages,
];
}
}