You are here

public function TeamAppListByTeamAccess::access in Apigee Edge 8

Grant access to Team app list by team page.

Parameters

\Drupal\apigee_edge_teams\Entity\TeamInterface $team: The team entity from the route.

\Drupal\Core\Session\AccountInterface $account: The currently logged in account.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

File

modules/apigee_edge_teams/src/Access/TeamAppListByTeamAccess.php, line 76

Class

TeamAppListByTeamAccess
Check access on Team app list by team route.

Namespace

Drupal\apigee_edge_teams\Access

Code

public function access(TeamInterface $team, AccountInterface $account) {
  $team_app_admin_permission = $this->entityTypeManager
    ->getDefinition('team_app')
    ->getAdminPermission();
  $result = AccessResult::allowedIfHasPermissions($account, [
    TeamAppPermissionProvider::MANAGE_TEAM_APPS_PERMISSION,
    $team_app_admin_permission,
  ], 'OR')
    ->cachePerUser();
  if ($result
    ->isNeutral()) {
    if ($account
      ->isAuthenticated()) {
      $result = AccessResult::allowedIf(in_array('team_app_view', $this->teamPermissionHandler
        ->getDeveloperPermissionsByTeam($team, $account)));
      $result
        ->addCacheableDependency($account);
    }
  }
  return $result
    ->addCacheableDependency($team);
}