You are here

function _social_event_get_enrollment_status in Open Social 8.9

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_event/social_event.module \_social_event_get_enrollment_status()
  2. 10.0.x modules/social_features/social_event/social_event.module \_social_event_get_enrollment_status()
  3. 10.1.x modules/social_features/social_event/social_event.module \_social_event_get_enrollment_status()
  4. 10.2.x modules/social_features/social_event/social_event.module \_social_event_get_enrollment_status()

Callback to get enrollment status from current user.

Parameters

\Drupal\node\NodeInterface $event: Event entity.

Return value

bool Enrolment status.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 call to _social_event_get_enrollment_status()
social_event_preprocess_field in modules/social_features/social_event/social_event.module
Implements hook_preprocess_field().

File

modules/social_features/social_event/social_event.module, line 1074
The Social event module.

Code

function _social_event_get_enrollment_status(NodeInterface $event) {
  $enrollments = \Drupal::entityTypeManager()
    ->getStorage('event_enrollment')
    ->loadByProperties([
    'field_account' => \Drupal::currentUser()
      ->id(),
    'field_event' => $event
      ->id(),
  ]);
  $status = TRUE;
  if ($enrollment = array_pop($enrollments)) {
    $enrollment_status = $enrollment->field_enrollment_status->value;
    if ($enrollment_status === '0') {
      $status = FALSE;
    }
  }
  else {
    $status = FALSE;
  }
  return $status;
}