function ThemeHooks::elementInfoAlter
Same name and namespace in other branches
- 11.x core/themes/admin/src/Hook/ThemeHooks.php \Drupal\admin\Hook\ThemeHooks::elementInfoAlter()
Implements hook_element_info_alter().
Attributes
#[Hook('element_info_alter')]
File
-
core/
themes/ admin/ src/ Hook/ ThemeHooks.php, line 75
Class
- ThemeHooks
- Provides theme related hook implementations.
Namespace
Drupal\admin\HookCode
public function elementInfoAlter(array &$info) : void {
// Add a pre-render function that handles the sidebar of the node form.
// @todo Refactor when https://www.drupal.org/node/3056089 is in.
if (isset($info['container'])) {
$container_pre_renders = !empty($info['container']['#pre_render']) ? $info['container']['#pre_render'] : [];
array_unshift($container_pre_renders, [
__CLASS__,
'container',
]);
$info['container']['#pre_render'] = $container_pre_renders;
}
// @todo Refactor when https://www.drupal.org/node/3016343 is fixed.
if (isset($info['text_format'])) {
$info['text_format']['#pre_render'][] = [
__CLASS__,
'textFormat',
];
}
// Add a pre-render function for Operations to set #dropbutton_type.
if (isset($info['operations'])) {
// In admin, operations should always use the extrasmall dropbutton
// variant.
// To add CSS classes based on variants, the element must have the
// #dropbutton_type property before it is processed by
// \Drupal\Core\Render\Element\Dropbutton::preRenderDropbutton(). This
// ensures #dropbutton_type is available to preRenderDropbutton().
$operations_pre_renders = !empty($info['operations']['#pre_render']) ? $info['operations']['#pre_render'] : [];
array_unshift($operations_pre_renders, [
__CLASS__,
'operations',
]);
$info['operations']['#pre_render'] = $operations_pre_renders;
// @todo Remove when https://www.drupal.org/node/1945262 is fixed.
$info['operations']['#attached']['library'][] = 'core/drupal.dialog.ajax';
}
if (isset($info['vertical_tabs'])) {
$info['vertical_tabs']['#pre_render'][] = [
__CLASS__,
'verticalTabs',
];
}
// Add a pre-render to managed_file.
if (isset($info['managed_file'])) {
$info['managed_file']['#pre_render'][] = [
__CLASS__,
'managedFile',
];
}
// Add a pre-render to status_messages to alter the placeholder markup.
if (isset($info['status_messages'])) {
$info['status_messages']['#pre_render'][] = [
__CLASS__,
'messagePlaceholder',
];
}
if (array_key_exists('text_format', $info)) {
$info['text_format']['#pre_render'][] = [
__CLASS__,
'textFormat',
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.