You are here

protected function RemoveTeamMemberForm::getDeveloperLabel in Apigee Edge 8

Returns the label for a developer.

Return value

string The label for a developer.

2 calls to RemoveTeamMemberForm::getDeveloperLabel()
RemoveTeamMemberForm::getQuestion in modules/apigee_edge_teams/src/Form/RemoveTeamMemberForm.php
Returns the question to ask the user.
RemoveTeamMemberForm::submitForm in modules/apigee_edge_teams/src/Form/RemoveTeamMemberForm.php
Form submission handler.

File

modules/apigee_edge_teams/src/Form/RemoveTeamMemberForm.php, line 178

Class

RemoveTeamMemberForm
Remove team members from.

Namespace

Drupal\apigee_edge_teams\Form

Code

protected function getDeveloperLabel() {
  $developer_label = $this->developer
    ->getEmail();

  // The developer that we would like to remove from the team may not have
  // a Drupal user yet (the two system is out of sync). To resolve this
  // possible problem we always try to display the label of the user first
  // and we fallback to the developer's email if necessary. We only display
  // the email here because this is what a user could see on the team member
  // list as well.
  // @see \Drupal\apigee_edge_teams\Controller\TeamMembersList::buildRow()
  $users = $this->userStorage
    ->loadByProperties([
    'mail' => $this->developer
      ->getEmail(),
  ]);
  if (!empty($users)) {

    /** @var \Drupal\user\UserInterface $user */
    $user = reset($users);
    $developer_label = $user
      ->label();
  }
  return $developer_label;
}