You are here

protected function TeamMembersList::getOperations in Apigee Edge 8

Returns available operations for a member.

Parameters

string $member: The email address of a member (developer).

\Drupal\apigee_edge_teams\Entity\TeamInterface $team: The team that the member belongs.

Return value

array Array of operation links.

1 call to TeamMembersList::getOperations()
TeamMembersList::buildOperations in modules/apigee_edge_teams/src/Controller/TeamMembersList.php
Builds operations for a member.

File

modules/apigee_edge_teams/src/Controller/TeamMembersList.php, line 255

Class

TeamMembersList
Team members list builder for a team.

Namespace

Drupal\apigee_edge_teams\Controller

Code

protected function getOperations(string $member, TeamInterface $team) {
  $operations = [];
  $url = Url::fromRoute('entity.team.member.edit', [
    'team' => $team
      ->id(),
    'developer' => $member,
  ], [
    'query' => [
      'destination' => $team
        ->toUrl('members')
        ->toString(),
    ],
  ]);
  if ($url
    ->access()) {
    $operations['edit'] = [
      'title' => $this
        ->t('Edit'),
      'url' => $url,
    ];
  }
  $url = Url::fromRoute('entity.team.member.remove', [
    'team' => $team
      ->id(),
    'developer' => $member,
  ], [
    'query' => [
      'destination' => $team
        ->toUrl('members')
        ->toString(),
    ],
  ]);
  if ($url
    ->access()) {
    $operations['remove'] = [
      'title' => $this
        ->t('Remove'),
      'url' => $url,
    ];
  }

  // Allow modules to alter operations.
  $this->moduleHandler
    ->alter('entity_operation', $operations, $team);
  return $operations;
}