function DemoUmamiHooks::navigationContentTop

Same name and namespace in other branches
  1. 11.x core/profiles/demo_umami/src/Hook/DemoUmamiHooks.php \Drupal\demo_umami\Hook\DemoUmamiHooks::navigationContentTop()

Implements hook_navigation_content_top().

Attributes

#[Hook('navigation_content_top')]

File

core/profiles/demo_umami/src/Hook/DemoUmamiHooks.php, line 147

Class

DemoUmamiHooks
Hook implementations for demo_umami.

Namespace

Drupal\demo_umami\Hook

Code

public function navigationContentTop() : array {
  // 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
  $build = [
    'experimental-profile-warning' => [
      '#weight' => 3400,
      '#cache' => [
        'contexts' => [
          'user.permissions',
        ],
      ],
    ],
  ];
  $link_to_help_page = $this->moduleHandler
    ->moduleExists('help') && $this->currentUser
    ->hasPermission('access help pages');
  $url = $link_to_help_page ? Url::fromRoute('help.page', [
    'name' => 'demo_umami',
  ])->toString() : 'https://www.drupal.org/node/2941833';
  $build['experimental-profile-warning'] += [
    '#theme' => 'navigation__messages',
    '#message_list' => [
      [
        '#theme' => 'navigation__message',
        '#content' => [
          '#markup' => $this->t('This site is intended for demonstration purposes.'),
        ],
        '#url' => $url,
        '#type' => 'warning',
      ],
    ],
  ];
  return $build;
}

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