function Dropbutton::preRenderDropbutton

Same name in other branches
  1. 9 core/lib/Drupal/Core/Render/Element/Dropbutton.php \Drupal\Core\Render\Element\Dropbutton::preRenderDropbutton()
  2. 10 core/lib/Drupal/Core/Render/Element/Dropbutton.php \Drupal\Core\Render\Element\Dropbutton::preRenderDropbutton()
  3. 11.x core/lib/Drupal/Core/Render/Element/Dropbutton.php \Drupal\Core\Render\Element\Dropbutton::preRenderDropbutton()

Pre-render callback: Attaches the dropbutton library and required markup.

File

core/lib/Drupal/Core/Render/Element/Dropbutton.php, line 63

Class

Dropbutton
Provides a render element for a set of links rendered as a drop-down button.

Namespace

Drupal\Core\Render\Element

Code

public static function preRenderDropbutton($element) {
    $element['#attached']['library'][] = 'core/drupal.dropbutton';
    $element['#attributes']['class'][] = 'dropbutton';
    if (!empty($element['#dropbutton_type'])) {
        $element['#attributes']['class'][] = 'dropbutton--' . $element['#dropbutton_type'];
    }
    if (!isset($element['#theme_wrappers'])) {
        $element['#theme_wrappers'] = [];
    }
    array_unshift($element['#theme_wrappers'], 'dropbutton_wrapper');
    // Enable targeted theming of specific dropbuttons (e.g., 'operations' or
    // 'operations__node').
    if (isset($element['#subtype'])) {
        $element['#theme'] .= '__' . $element['#subtype'];
    }
    return $element;
}

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