You are here

public function EventAnEnrollService::isEnrolled in Open Social 8.7

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollService.php \Drupal\social_event_an_enroll\EventAnEnrollService::isEnrolled()
  2. 8.5 modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollService.php \Drupal\social_event_an_enroll\EventAnEnrollService::isEnrolled()
  3. 8.6 modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollService.php \Drupal\social_event_an_enroll\EventAnEnrollService::isEnrolled()
  4. 8.8 modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollService.php \Drupal\social_event_an_enroll\EventAnEnrollService::isEnrolled()
  5. 10.3.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollService.php \Drupal\social_event_an_enroll\EventAnEnrollService::isEnrolled()
  6. 10.0.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollService.php \Drupal\social_event_an_enroll\EventAnEnrollService::isEnrolled()
  7. 10.1.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollService.php \Drupal\social_event_an_enroll\EventAnEnrollService::isEnrolled()
  8. 10.2.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollService.php \Drupal\social_event_an_enroll\EventAnEnrollService::isEnrolled()

Checks if a visitor is enrolled.

Return value

bool Returns TRUE if the visitor is enrolled to this event, otherwise FALSE.

File

modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollService.php, line 105

Class

EventAnEnrollService
Class EventAnEnrollService.

Namespace

Drupal\social_event_an_enroll

Code

public function isEnrolled() {

  // Make sure the current user is anonymous.
  if (!$this->currentUser
    ->isAnonymous()) {
    return FALSE;
  }

  // Get the token and Node ID from the route.
  $token = $this->currentRouteMatch
    ->getParameter('token');

  /** @var \Drupal\node\NodeInterface $node */
  $node = $this->currentRouteMatch
    ->getParameter('node');

  // If some data is missing we can already return FALSE.
  if (!empty($token) || !empty($node)) {
    return FALSE;
  }

  // Check if the token is valid.
  return $this
    ->tokenExists($token, $node
    ->id());
}