You are here

function claro_element_info_alter in Drupal 8

Same name and namespace in other branches
  1. 9 core/themes/claro/claro.theme \claro_element_info_alter()
  2. 10 core/themes/claro/claro.theme \claro_element_info_alter()

Implements hook_element_info_alter().

File

core/themes/claro/claro.theme, line 232
Functions to support theming in the Claro theme.

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 that handles dropbutton variants.
  if (isset($type['dropbutton'])) {
    $type['dropbutton']['#pre_render'][] = [
      ClaroPreRender::class,
      'dropButton',
    ];
  }
  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',
    ];
  }
}