From b2dd6e6207a5cad60272d4cff7e37e38dee307ed Mon Sep 17 00:00:00 2001 From: Jens Schuppe Date: Mon, 13 Nov 2023 14:46:07 +0100 Subject: [PATCH] Retrieve cancellation form also when not using tokens --- .../src/Form/RegistrationCancelForm.php | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/modules/civiremote_event/src/Form/RegistrationCancelForm.php b/modules/civiremote_event/src/Form/RegistrationCancelForm.php index c82c4dd..4ca666f 100644 --- a/modules/civiremote_event/src/Form/RegistrationCancelForm.php +++ b/modules/civiremote_event/src/Form/RegistrationCancelForm.php @@ -78,28 +78,27 @@ public function __construct(CiviMRF $cmrf) { $routeMatch = RouteMatch::createFromRequest($this->getRequest()); $this->event = $routeMatch->getParameter('event'); $this->remote_token = $routeMatch->getRawParameter('event_token'); - // Retrieve event using the remote token, overwriting the event object. - if (!empty($this->remote_token)) { - try { - $form = $this->cmrf->getForm( - (isset($this->event) ? $this->event->id : NULL), - NULL, - $this->remote_token, - 'cancel' - ); - $this->fields = $form['values']; - $this->messages = isset($form['status_messages']) ? $form['status_messages'] : []; + try { + $form = $this->cmrf->getForm( + (isset($this->event) ? $this->event->id : NULL), + NULL, + $this->remote_token, + 'cancel' + ); + $this->fields = $form['values']; + $this->messages = isset($form['status_messages']) ? $form['status_messages'] : []; + if (!$this->event) { $this->event = $this->cmrf->getEvent( $this->fields['event_id']['value'], $this->remote_token ); } - catch (Exception $exception) { - Drupal::messenger()->addMessage( - $exception->getMessage(), - MessengerInterface::TYPE_ERROR - ); - } + } + catch (Exception $exception) { + Drupal::messenger()->addMessage( + $exception->getMessage(), + MessengerInterface::TYPE_ERROR + ); } }