public function Core::alterToolbarWidget in BUEditor 8.2
Same name and namespace in other branches
- 8 src/Plugin/BUEditorPlugin/Core.php \Drupal\bueditor\Plugin\BUEditorPlugin\Core::alterToolbarWidget()
Alters the toolbar widget used in BUEditor Editor form.
Parameters
array $widget: An associative array that holds 'libraries' and 'items' in it.
Overrides BUEditorPluginBase::alterToolbarWidget
File
- src/
Plugin/ BUEditorPlugin/ Core.php, line 76
Class
- Core
- Defines BUEditor Core plugin.
Namespace
Drupal\bueditor\Plugin\BUEditorPluginCode
public function alterToolbarWidget(array &$widget) {
// Add custom button definitions.
foreach (\Drupal::entityTypeManager()
->getStorage('bueditor_button')
->loadMultiple() as $bid => $button) {
$item = $button
->jsProperties();
// Define template buttons as normal buttons with a special class name.
if (!empty($item['template']) && empty($item['code'])) {
$item['cname'] = 'template-button ficon-template' . (!empty($item['cname']) ? ' ' . $item['cname'] : '');
$item['text'] = '<span class="template-button-text">' . (empty($item['text']) ? Html::escape($item['label']) : $item['text']) . '</span>';
$item['label'] = '[' . $this
->t('Template') . ']' . $item['label'];
$item['multiple'] = TRUE;
}
// Remove unneeded properties.
unset($item['template'], $item['code']);
$widget['items'][$bid] = $item;
}
}