function claro_element_info_alter

Same name in other branches
  1. 9 core/themes/claro/claro.theme \claro_element_info_alter()
  2. 8.9.x core/themes/claro/claro.theme \claro_element_info_alter()
  3. 11.x core/themes/claro/claro.theme \claro_element_info_alter()

Implements hook_element_info_alter().

File

core/themes/claro/claro.theme, line 254

Code

function claro_element_info_alter(&$type) {
    // 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($type['container'])) {
        $container_pre_renders = !empty($type['container']['#pre_render']) ? $type['container']['#pre_render'] : [];
        array_unshift($container_pre_renders, [
            ClaroPreRender::class,
            'container',
        ]);
        $type['container']['#pre_render'] = $container_pre_renders;
    }
    // @todo Refactor when https://www.drupal.org/node/3016343 is fixed.
    if (isset($type['text_format'])) {
        $type['text_format']['#pre_render'][] = [
            ClaroPreRender::class,
            'textFormat',
        ];
    }
    // Add a pre-render function for Operations to set #dropbutton_type.
    if (isset($type['operations'])) {
        // In Claro, 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($type['operations']['#pre_render']) ? $type['operations']['#pre_render'] : [];
        array_unshift($operations_pre_renders, [
            ClaroPreRender::class,
            'operations',
        ]);
        $type['operations']['#pre_render'] = $operations_pre_renders;
        // @todo Remove when https://www.drupal.org/node/1945262 is fixed.
        $type['operations']['#attached']['library'][] = 'core/drupal.dialog.ajax';
    }
    if (isset($type['vertical_tabs'])) {
        $type['vertical_tabs']['#pre_render'][] = [
            ClaroPreRender::class,
            'verticalTabs',
        ];
    }
    // Add a pre-render to managed_file.
    if (isset($type['managed_file'])) {
        $type['managed_file']['#pre_render'][] = [
            ClaroPreRender::class,
            'managedFile',
        ];
    }
    // Add a pre-render to status_messages to alter the placeholder markup.
    if (isset($type['status_messages'])) {
        $type['status_messages']['#pre_render'][] = [
            ClaroPreRender::class,
            'messagePlaceholder',
        ];
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.