You are here

public function CancelEnrollInviteController::cancelEnrollmentInvite in Open Social 8.9

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_event/modules/social_event_invite/src/Controller/CancelEnrollInviteController.php \Drupal\social_event_invite\Controller\CancelEnrollInviteController::cancelEnrollmentInvite()
  2. 10.0.x modules/social_features/social_event/modules/social_event_invite/src/Controller/CancelEnrollInviteController.php \Drupal\social_event_invite\Controller\CancelEnrollInviteController::cancelEnrollmentInvite()
  3. 10.1.x modules/social_features/social_event/modules/social_event_invite/src/Controller/CancelEnrollInviteController.php \Drupal\social_event_invite\Controller\CancelEnrollInviteController::cancelEnrollmentInvite()
  4. 10.2.x modules/social_features/social_event/modules/social_event_invite/src/Controller/CancelEnrollInviteController.php \Drupal\social_event_invite\Controller\CancelEnrollInviteController::cancelEnrollmentInvite()

Updates the enrollment request.

Parameters

\Drupal\node\NodeInterface $node: The current event node.

\Drupal\social_event\EventEnrollmentInterface $event_enrollment: The entity event_enrollment.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse Return to the original destination from the current request.

Throws

\Drupal\Core\Entity\EntityStorageException

1 string reference to 'CancelEnrollInviteController::cancelEnrollmentInvite'
social_event_invite.routing.yml in modules/social_features/social_event/modules/social_event_invite/social_event_invite.routing.yml
modules/social_features/social_event/modules/social_event_invite/social_event_invite.routing.yml

File

modules/social_features/social_event/modules/social_event_invite/src/Controller/CancelEnrollInviteController.php, line 73

Class

CancelEnrollInviteController
Cancels a pending enrollment invite.

Namespace

Drupal\social_event_invite\Controller

Code

public function cancelEnrollmentInvite(NodeInterface $node, EventEnrollmentInterface $event_enrollment) {

  // Just some sanity checks.
  if ($node instanceof Node && !empty($event_enrollment)) {

    // When the event owner/organizer cancelled the invite, simply remove the
    // whole event enrollment.
    $this
      ->messenger()
      ->addStatus(t('The invite has been removed.'));
    $event_enrollment
      ->delete();
  }

  // Get the redirect destination we're given in the request for the response.
  $destination = $this->requestStack
    ->getCurrentRequest()->query
    ->get('destination');
  return new RedirectResponse($destination);
}