You are here

public function GroupMenuService::loadUserGroupMenus in Group Menu 8

Load a list of menus where a user can perform a operation.

Parameters

string $op: The operation to perform on the menu.

\Drupal\Core\Session\AccountInterface $account: The user to load the menus for.

Return value

\Drupal\system\MenuInterface[] An array of menu objects keyed by menu name.

Overrides GroupMenuServiceInterface::loadUserGroupMenus

File

src/GroupMenuService.php, line 139

Class

GroupMenuService
Checks access for displaying menu pages.

Namespace

Drupal\groupmenu

Code

public function loadUserGroupMenus($op, AccountInterface $account = NULL) {
  if (!isset($account)) {
    $account = $this->currentUser;
  }
  if (isset($this->userMenus[$op][$account
    ->id()])) {
    return $this->userMenus[$op][$account
      ->id()];
  }
  $group_memberships = $this->membershipLoader
    ->loadByUser($account);
  $this->userMenus[$op][$account
    ->id()] = [];
  foreach ($group_memberships as $group_membership) {
    $this->userMenus[$op][$account
      ->id()] += $this
      ->loadUserGroupMenusByGroup($op, $group_membership
      ->getGroupContent()->gid->target_id, $account);
  }
  return $this->userMenus[$op][$account
    ->id()];
}