protected function TeamMembersList::buildRow in Apigee Edge 8
Builds a row for a team member.
Parameters
string $member: The email address of a member (developer).
array $users_by_mail: Associative array of Drupal users keyed by their email addresses. The list only contains those Drupal users who are member of the team.
\Drupal\apigee_edge_teams\Entity\TeamMemberRoleInterface[] $team_member_roles_by_mail: Associative array of team member roles keyed by email addresses.
\Drupal\apigee_edge_teams\Entity\TeamInterface $team: The team that the member belongs.
Return value
array Render array.
1 call to TeamMembersList::buildRow()
- TeamMembersList::overview in modules/
apigee_edge_teams/ src/ Controller/ TeamMembersList.php - Returns a list of team members.
File
- modules/
apigee_edge_teams/ src/ Controller/ TeamMembersList.php, line 182
Class
- TeamMembersList
- Team members list builder for a team.
Namespace
Drupal\apigee_edge_teams\ControllerCode
protected function buildRow(string $member, array $users_by_mail, array $team_member_roles_by_mail, TeamInterface $team) : array {
$row = [];
$row['id'] = Html::getUniqueId($member);
if (array_key_exists($member, $users_by_mail)) {
// @see \Drupal\user\UserAccessControlHandler::checkAccess()
$row['data']['member'] = $users_by_mail[$member]
->access('view') ? $users_by_mail[$member]
->toLink() : "{$users_by_mail[$member]->label()} ({$member})";
}
else {
// We only display the email address of the member in this case
// because displaying its first name and last name would require API
// call(s). We can not load only a set of developers from Apigee Edge
// (like we loaded only the necessary amount of Drupal users), we can only
// all developers which could unnecessarily slow down this page if the
// developer entity cache is cold.
$row['data']['member'] = $member;
}
if (array_key_exists($member, $team_member_roles_by_mail)) {
$roles = array_reduce($team_member_roles_by_mail[$member]
->getTeamRoles(), function ($carry, TeamRoleInterface $role) {
$carry[$role
->id()] = $role
->label();
return $carry;
}, $this->defaultRoles);
$row['data']['roles']['data'] = [
'#theme' => 'item_list',
'#items' => $roles,
'#cache' => [
'contexts' => $team_member_roles_by_mail[$member]
->getCacheContexts(),
'tags' => $team_member_roles_by_mail[$member]
->getCacheTags(),
],
];
}
else {
$row['data']['roles']['data'] = [
'#theme' => 'item_list',
'#items' => $this->defaultRoles,
];
}
$row['data']['operations']['data'] = $this
->buildOperations($member, $team);
return $row;
}