You are here

function notifications_widget_page_top in Notifications widget 8

Implements hook_page_top().

File

./notifications_widget.module, line 33
Contains notifications_widget.module.

Code

function notifications_widget_page_top() {

  /** @var \Drupal\Core\Routing\AdminContext $admin_context */
  $admin_context = \Drupal::service('router.admin_context');
  $route_match = \Drupal::routeMatch();
  if ($admin_context
    ->isAdminRoute($route_match
    ->getRouteObject()) && \Drupal::currentUser()
    ->hasPermission('administer site configuration')) {
    $route_name = \Drupal::routeMatch()
      ->getRouteName();
    switch ($route_name) {

      // These pages don't need additional nagging.
      case 'update.theme_update':
      case 'system.theme_install':
      case 'update.module_update':
      case 'update.module_install':
      case 'update.status':
      case 'update.report_update':
      case 'update.report_install':
      case 'update.settings':
      case 'system.status':
      case 'update.confirmation_page':
        return;
    }
    $config = \Drupal::config('notifications_widget.settings');
    if (!$config
      ->get('notfication_widget_conf')) {
      \Drupal::messenger()
        ->addMessage(t('Notification widget will work well once you saved the configuration from <a href=":user_settings_url">Notification Widget Settings</a>.', [
        ':user_settings_url' => Url::fromRoute('notifications_widget.notifications_widget_settings')
          ->toString(),
      ]), 'warning');
    }
  }
}