You are here

public function TeamInvitationResendForm::submitForm in Apigee Edge 8

This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state can be updated, this way the subsequently invoked handlers can retrieve a regular entity object to act on. Generally this method should not be overridden unless the entity requires the same preparation for two actions, see \Drupal\comment\CommentForm for an example with the save and preview actions.

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 ContentEntityForm::submitForm

File

modules/apigee_edge_teams/src/Entity/Form/TeamInvitationResendForm.php, line 93

Class

TeamInvitationResendForm
Provides the resend form for team_invitation.

Namespace

Drupal\apigee_edge_teams\Entity\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  /** @var \Drupal\apigee_edge_teams\Entity\TeamInvitationInterface $team_invitation */
  $team_invitation = $this->entity;

  // Reset the status and the expiry date.
  $team_invitation
    ->setStatus(TeamInvitationInterface::STATUS_PENDING);
  $days = $this
    ->config('apigee_edge_teams.team_settings')
    ->get('team_invitation_expiry_days');
  $team_invitation
    ->setExpiryTime($this->time
    ->getCurrentTime() + 24 * 60 * 60 * (int) $days);
  $team_invitation
    ->save();
  if ($this->teamInvitationNotifier
    ->sendNotificationsFor($team_invitation)) {
    $this
      ->messenger()
      ->addMessage($this
      ->t('The invitation to join the %team team has been resent to %recipient.', [
      '%team' => $team_invitation
        ->getTeam()
        ->label(),
      '%recipient' => $team_invitation
        ->getRecipient(),
    ]));
  }
  $form_state
    ->setRedirectUrl($this->team
    ->toUrl('members'));
}