function DemoUmamiHooks::navigationContentTop
Implements hook_navigation_content_top().
File
-
core/
profiles/ demo_umami/ src/ Hook/ DemoUmamiHooks.php, line 151
Class
- DemoUmamiHooks
- Hook implementations for demo_umami.
Namespace
Drupal\demo_umami\HookCode
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' => [
'route',
'user.permissions',
],
],
],
];
// Show warning only on administration pages.
if (!$this->adminContext
->isAdminRoute()) {
return $build;
}
$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.