function ToolbarHooks::demoUmamiToolbar

1 call to ToolbarHooks::demoUmamiToolbar()
ToolbarHooks::toolbar in core/modules/toolbar/src/Hook/ToolbarHooks.php
Implements hook_toolbar().

File

core/modules/toolbar/src/Hook/ToolbarHooks.php, line 258

Class

ToolbarHooks
Hook implementations for toolbar.

Namespace

Drupal\toolbar\Hook

Code

protected function demoUmamiToolbar() : array {
  // Add a warning about using an experimental profile.
  // @todo This can be removed once a generic warning for experimental
  //   profiles has been introduced in
  //   https://www.drupal.org/project/drupal/issues/2934374
  $items['experimental-profile-warning'] = [
    '#weight' => 3400,
    '#cache' => [
      'contexts' => [
        'route',
      ],
    ],
  ];
  // Show warning only on administration pages.
  if ($this->adminContext
    ->isAdminRoute()) {
    $link_to_help_page = $this->moduleHandler
      ->moduleExists('help') && $this->currentUser
      ->hasPermission('access help pages');
    $items['experimental-profile-warning']['#type'] = 'toolbar_item';
    $items['experimental-profile-warning']['tab'] = [
      '#type' => 'inline_template',
      '#template' => '<a class="toolbar-warning" href="{{ more_info_link }}">This site is intended for demonstration purposes.</a>',
      '#context' => [
        // Link directly to the drupal.org documentation if the help pages
        // aren't available.
'more_info_link' => $link_to_help_page ? Url::fromRoute('help.page', [
          'name' => 'demo_umami',
        ]) : 'https://www.drupal.org/node/2941833',
      ],
      '#attached' => [
        'library' => [
          'demo_umami/toolbar-warning',
        ],
      ],
    ];
  }
  return $items;
}

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