You are here

function admin_toolbar_links_access_filter_is_overview_page in Admin Toolbar 8

Same name and namespace in other branches
  1. 8.2 admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module \admin_toolbar_links_access_filter_is_overview_page()
  2. 3.x admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module \admin_toolbar_links_access_filter_is_overview_page()

Checks if the given route name is an overview page.

Checks if the given route name matches a pure (admin) overview page that can be skipped, if there are no child items set. The typical example are routes having the SystemController::systemAdminMenuBlockPage() function as their controller callback set.

Parameters

string $route_name: The route name to check.

Return value

bool TRUE, if the given route name matches a pure admin overview page route, FALSE otherwise.

1 call to admin_toolbar_links_access_filter_is_overview_page()
admin_toolbar_links_access_filter_filter_non_accessible_links in admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module
Hides links from admin menu, if user doesn't have access rights.

File

admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module, line 121
This module don't show menu links that you don't have access permission for.

Code

function admin_toolbar_links_access_filter_is_overview_page($route_name) {

  // @var \Drupal\Core\Routing\RouteProviderInterface $route_provider.
  $route_provider = \Drupal::service('router.route_provider');
  $overview_page_controllers = [
    '\\Drupal\\system\\Controller\\AdminController::index',
    '\\Drupal\\system\\Controller\\SystemController::overview',
    '\\Drupal\\system\\Controller\\SystemController::systemAdminMenuBlockPage',
  ];
  try {
    $route = $route_provider
      ->getRouteByName($route_name);
    $controller = $route
      ->getDefault('_controller');
    return !empty($controller) && in_array($controller, $overview_page_controllers);
  } catch (RouteNotFoundException $ex) {
  }
  return FALSE;
}