function PreprocessHooks::topBar

Same name and namespace in other branches
  1. 11.x core/themes/admin/src/Hook/PreprocessHooks.php \Drupal\admin\Hook\PreprocessHooks::topBar()

Implements hook_preprocess_HOOK() for top_bar.

Attributes

#[Hook('preprocess_top_bar')]

File

core/themes/admin/src/Hook/PreprocessHooks.php, line 1317

Class

PreprocessHooks
Provides preprocess implementations.

Namespace

Drupal\admin\Hook

Code

public function topBar(array &$variables) : void {
  if (!$this->moduleHandler
    ->moduleExists('navigation')) {
    return;
  }
  // Get local actions.
  $plugin_block = $this->blockManager
    ->createInstance('local_actions_block', []);
  $block_content = $plugin_block->build();
  $variables['gin_local_actions'] = $this->renderer
    ->render($block_content);
  $variables['#attached']['library'][] = 'admin/top_bar';
  // Get form actions.
  if ($form_actions = Helper::formActions()) {
    $variables['gin_form_actions'] = $form_actions;
    $variables['gin_form_actions_class'] = 'gin-sticky-form-actions--preprocessed';
    $variables['#attached']['library'][] = 'admin/top_bar';
  }
  // Get breadcrumb.
  $plugin_block = $this->blockManager
    ->createInstance('system_breadcrumb_block', []);
  $block_content = $plugin_block->build();
  $variables['gin_breadcrumbs'] = $this->renderer
    ->render($block_content);
  $variables['#attached']['library'][] = 'admin/top_bar';
}

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