function demo_umami_toolbar

Same name in other branches
  1. 9 core/profiles/demo_umami/demo_umami.profile \demo_umami_toolbar()
  2. 10 core/profiles/demo_umami/demo_umami.profile \demo_umami_toolbar()
  3. 11.x core/profiles/demo_umami/demo_umami.profile \demo_umami_toolbar()

Implements hook_toolbar().

File

core/profiles/demo_umami/demo_umami.profile, line 52

Code

function demo_umami_toolbar() {
    // Add a warning about using an experimental profile.
    // @todo This can be removed once a generic warning for experimental profiles
    //   has been introduced. https://www.drupal.org/project/drupal/issues/2934374
    $items['experimental-profile-warning'] = [
        '#weight' => 999,
        '#cache' => [
            'contexts' => [
                'route',
            ],
        ],
    ];
    // Show warning only on administration pages.
    $admin_context = \Drupal::service('router.admin_context');
    if ($admin_context->isAdminRoute()) {
        $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' => [
                'more_info_link' => '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.