diff --git a/modules/apigee_edge_teams/src/Controller/TeamMembersList.php b/modules/apigee_edge_teams/src/Controller/TeamMembersList.php index 5f88648c5..1a786a401 100644 --- a/modules/apigee_edge_teams/src/Controller/TeamMembersList.php +++ b/modules/apigee_edge_teams/src/Controller/TeamMembersList.php @@ -43,6 +43,13 @@ class TeamMembersList extends ControllerBase { */ private $teamMembershipManager; + /** + * Default member roles. + * + * @var array + */ + protected $defaultRoles = []; + /** * TeamMembersList constructor. * @@ -54,6 +61,10 @@ class TeamMembersList extends ControllerBase { public function __construct(TeamMembershipManagerInterface $team_membership_manager, EntityTypeManagerInterface $entity_type_manager) { $this->teamMembershipManager = $team_membership_manager; $this->entityTypeManager = $entity_type_manager; + + if ($role = $this->entityTypeManager()->getStorage('team_role')->load(TeamRoleInterface::TEAM_MEMBER_ROLE)) { + $this->defaultRoles = [$role->id() => $role->label()]; + } } /** @@ -164,7 +175,7 @@ protected function buildRow(string $member, array $users_by_mail, array $team_me $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, @@ -175,7 +186,10 @@ protected function buildRow(string $member, array $users_by_mail, array $team_me ]; } else { - $row['data']['roles']['data'] = NULL; + $row['data']['roles']['data'] = [ + '#theme' => 'item_list', + '#items' => $this->defaultRoles, + ]; } $row['data']['operations']['data'] = $this->buildOperations($member, $team);