function _boxout_update_editors in Boxout 8
Helper to configure Boxout on editors.
2 calls to _boxout_update_editors()
- boxout_install in ./
boxout.install - Implements hook_install().
- boxout_update_8001 in ./
boxout.install - Update filter.
File
- ./
boxout.install, line 13 - Install/Update hooks for Boxout.
Code
function _boxout_update_editors() {
foreach ([
'basic_html',
'full_html',
] as $id) {
if ($editor = Editor::load($id)) {
switch ($id) {
case 'basic_html':
// Add boxout to allowed html.
$config = \Drupal::configFactory()
->getEditable('filter.format.basic_html');
$key = 'filters.filter_html.settings.allowed_html';
$config_value = $config
->get($key);
$config_value .= '<div class="boxout default plain">';
$config
->set($key, $config_value)
->save(TRUE);
break;
}
$config = $editor
->getSettings();
// Add boxout to toolbar.
foreach ($config['toolbar']['rows'][0] as &$row) {
// Try to add Boxout on toolbar.
if ($row['name'] == 'Tools') {
if (!array_search('Boxout', $row['items'])) {
$row['items'][] = 'Boxout';
}
}
}
// Save settings.
$editor
->setSettings($config);
$editor
->save();
\Drupal::service('plugin.manager.editor')
->clearCachedDefinitions();
}
}
}