public function SocialEmbedEditorConfigOverride::loadOverrides in Open Social 8.2
Same name and namespace in other branches
- 8 modules/social_features/social_embed/src/SocialEmbedEditorConfigOverride.php \Drupal\social_embed\SocialEmbedEditorConfigOverride::loadOverrides()
- 8.3 modules/social_features/social_embed/src/SocialEmbedEditorConfigOverride.php \Drupal\social_embed\SocialEmbedEditorConfigOverride::loadOverrides()
Returns config overrides.
Parameters
array $names: A list of configuration names that are being loaded.
Return value
array An array keyed by configuration name of override data. Override data contains a nested array structure of overrides.
Overrides ConfigFactoryOverrideInterface::loadOverrides
File
- modules/
social_features/ social_embed/ src/ SocialEmbedEditorConfigOverride.php, line 19
Class
- SocialEmbedEditorConfigOverride
- Class SocialEmbedEditorConfigOverride.
Namespace
Drupal\social_embedCode
public function loadOverrides($names) {
$overrides = [];
$config_names = [
'editor.editor.basic_html',
'editor.editor.full_html',
];
foreach ($config_names as $config_name) {
if (in_array($config_name, $names)) {
/* @var \Drupal\Core\Config\ConfigFactory $config */
$config = \Drupal::service('config.factory')
->getEditable($config_name);
if ($settings = $config
->get('settings')) {
if (isset($settings['toolbar']['rows']) && is_array($settings['toolbar']['rows'])) {
$button_exists = FALSE;
foreach ($settings['toolbar']['rows'] as $row_id => $row) {
foreach ($row as $group_id => $group) {
foreach ($group['items'] as $button_id => $button) {
if ($button === 'social_embed') {
$button_exists = TRUE;
}
}
}
}
if ($button_exists === FALSE) {
$row_array_keys = array_keys($settings['toolbar']['rows']);
$last_row_key = end($row_array_keys);
$group = [];
$group['name'] = 'Embed';
$group['items'] = [];
$group['items'][] = 'social_embed';
$settings['toolbar']['rows'][$last_row_key][] = $group;
$overrides[$config_name] = [
'settings' => $settings,
];
}
}
}
}
}
return $overrides;
}