class SocialEmbedEditorConfigOverride in Open Social 8.3
Same name and namespace in other branches
- 8 modules/social_features/social_embed/src/SocialEmbedEditorConfigOverride.php \Drupal\social_embed\SocialEmbedEditorConfigOverride
- 8.2 modules/social_features/social_embed/src/SocialEmbedEditorConfigOverride.php \Drupal\social_embed\SocialEmbedEditorConfigOverride
Class SocialEmbedEditorConfigOverride.
@package Drupal\social_embed
Hierarchy
- class \Drupal\social_embed\SocialEmbedEditorConfigOverride implements ConfigFactoryOverrideInterface
Expanded class hierarchy of SocialEmbedEditorConfigOverride
2 string references to 'SocialEmbedEditorConfigOverride'
- SocialEmbedEditorConfigOverride::getCacheSuffix in modules/
social_features/ social_embed/ src/ SocialEmbedEditorConfigOverride.php - The string to append to the configuration static cache name.
- social_embed.services.yml in modules/
social_features/ social_embed/ social_embed.services.yml - modules/social_features/social_embed/social_embed.services.yml
1 service uses SocialEmbedEditorConfigOverride
- social_embed_editor.overrider in modules/
social_features/ social_embed/ social_embed.services.yml - \Drupal\social_embed\SocialEmbedEditorConfigOverride
File
- modules/
social_features/ social_embed/ src/ SocialEmbedEditorConfigOverride.php, line 14
Namespace
Drupal\social_embedView source
class SocialEmbedEditorConfigOverride implements ConfigFactoryOverrideInterface {
/**
* {@inheritdoc}
*/
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;
}
/**
* {@inheritdoc}
*/
public function getCacheSuffix() {
return 'SocialEmbedEditorConfigOverride';
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata($name) {
return new CacheableMetadata();
}
/**
* {@inheritdoc}
*/
public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) {
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SocialEmbedEditorConfigOverride:: |
public | function |
Creates a configuration object for use during install and synchronization. Overrides ConfigFactoryOverrideInterface:: |
|
SocialEmbedEditorConfigOverride:: |
public | function |
Gets the cacheability metadata associated with the config factory override. Overrides ConfigFactoryOverrideInterface:: |
|
SocialEmbedEditorConfigOverride:: |
public | function |
The string to append to the configuration static cache name. Overrides ConfigFactoryOverrideInterface:: |
|
SocialEmbedEditorConfigOverride:: |
public | function |
Returns config overrides. Overrides ConfigFactoryOverrideInterface:: |