You are here

function hook_apigee_edge_teams_team_api_product_access in Apigee Edge 8

Control API product entity operation access of a team (and its members).

Parameters

\Drupal\apigee_edge\Entity\ApiProductInterface $api_product: The API Product entity for which to check access.

string $operation: The entity operation. Usually one of 'view', 'update', 'create', 'delete' or 'assign".

\Drupal\apigee_edge_teams\Entity\TeamInterface $team: The team for which to check access.

\Drupal\Core\Session\AccountInterface $account: The team member for which to check access.

Return value

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

See also

\Drupal\apigee_edge_teams\TeamMemberApiProductAccessHandler

1 invocation of hook_apigee_edge_teams_team_api_product_access()
TeamMemberApiProductAccessHandler::access in modules/apigee_edge_teams/src/TeamMemberApiProductAccessHandler.php
Checks access to an operation on a given API product.

File

modules/apigee_edge_teams/apigee_edge_teams.api.php, line 57
Copyright 2018 Google Inc.

Code

function hook_apigee_edge_teams_team_api_product_access(\Drupal\apigee_edge\Entity\ApiProductInterface $api_product, string $operation, \Drupal\apigee_edge_teams\Entity\TeamInterface $team, \Drupal\Core\Session\AccountInterface $account) {

  // Grant access if API product's name is prefixed with the team's name.
  return \Drupal\Core\Access\AccessResult::allowedIf(mb_strpos($api_product
    ->id(), $team
    ->id()) === 0);
}