You are here

public function MenuAdminPerMenuController::menuOverviewPage in Menu Admin per Menu 8

Constructs menus overview page.

File

src/Controller/MenuAdminPerMenuController.php, line 43

Class

MenuAdminPerMenuController
Controller routines for menu overview route.

Namespace

Drupal\menu_admin_per_menu\Controller

Code

public function menuOverviewPage() {
  $account = $this
    ->currentUser();
  $menu_table = $this
    ->entityTypeManager()
    ->getListBuilder('menu')
    ->render();
  if ($account
    ->hasPermission('administer menu')) {
    return $menu_table;
  }
  $allowed_menus = $this->allowedMenusService
    ->getPerMenuPermissions($account);
  foreach ($menu_table['table']['#rows'] as $menu_key => $menu_item) {
    if (!isset($allowed_menus["administer {$menu_key} menu items"])) {
      unset($menu_table['table']['#rows'][$menu_key]);
    }
  }
  return $menu_table;
}