You are here

public function RemoveTeamMemberForm::submitForm in Apigee Edge 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

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

Class

RemoveTeamMemberForm
Remove team members from.

Namespace

Drupal\apigee_edge_teams\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $context = [
    '%developer' => $this
      ->getDeveloperLabel(),
    '%developer_mail' => $this->developer
      ->getEmail(),
    '@team' => mb_strtolower($this->teamEntityType
      ->getSingularLabel()),
    '%team_id' => $this->team
      ->id(),
  ];
  $success = FALSE;
  try {
    $this->teamMembershipManager
      ->removeMembers($this->team
      ->id(), [
      $this->developer
        ->getEmail(),
    ]);
    $success = TRUE;
  } catch (\Exception $exception) {
    $context += Error::decodeException($exception);
    $this
      ->messenger()
      ->addError($this
      ->t('Failed to remove %developer developer from the @team. Please try again.', $context));
    $this
      ->logger('apigee_edge_teams')
      ->error('Failed to remove %developer_mail developer from %team_id @team. @message %function (line %line of %file). <pre>@backtrace_string</pre>', $context);
  }
  if ($success) {
    $this
      ->messenger()
      ->addStatus($this
      ->t('%developer successfully removed from the @team.', $context));
  }
}