public function EventMaxEnrollService::getEnrollmentsLeft in Open Social 10.1.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/modules/social_event_max_enroll/src/Service/EventMaxEnrollService.php \Drupal\social_event_max_enroll\Service\EventMaxEnrollService::getEnrollmentsLeft()
- 8.5 modules/social_features/social_event/modules/social_event_max_enroll/src/Service/EventMaxEnrollService.php \Drupal\social_event_max_enroll\Service\EventMaxEnrollService::getEnrollmentsLeft()
- 8.6 modules/social_features/social_event/modules/social_event_max_enroll/src/Service/EventMaxEnrollService.php \Drupal\social_event_max_enroll\Service\EventMaxEnrollService::getEnrollmentsLeft()
- 8.7 modules/social_features/social_event/modules/social_event_max_enroll/src/Service/EventMaxEnrollService.php \Drupal\social_event_max_enroll\Service\EventMaxEnrollService::getEnrollmentsLeft()
- 8.8 modules/social_features/social_event/modules/social_event_max_enroll/src/Service/EventMaxEnrollService.php \Drupal\social_event_max_enroll\Service\EventMaxEnrollService::getEnrollmentsLeft()
- 10.3.x modules/social_features/social_event/modules/social_event_max_enroll/src/Service/EventMaxEnrollService.php \Drupal\social_event_max_enroll\Service\EventMaxEnrollService::getEnrollmentsLeft()
- 10.0.x modules/social_features/social_event/modules/social_event_max_enroll/src/Service/EventMaxEnrollService.php \Drupal\social_event_max_enroll\Service\EventMaxEnrollService::getEnrollmentsLeft()
- 10.2.x modules/social_features/social_event/modules/social_event_max_enroll/src/Service/EventMaxEnrollService.php \Drupal\social_event_max_enroll\Service\EventMaxEnrollService::getEnrollmentsLeft()
Get number of enrollments still possible per event.
Parameters
\Drupal\node\NodeInterface $node: The node to check for.
Return value
int How many spots are left.
Overrides EventMaxEnrollServiceInterface::getEnrollmentsLeft
File
- modules/
social_features/ social_event/ modules/ social_event_max_enroll/ src/ Service/ EventMaxEnrollService.php, line 75
Class
- EventMaxEnrollService
- Class EventMaxEnrollService.
Namespace
Drupal\social_event_max_enroll\ServiceCode
public function getEnrollmentsLeft(NodeInterface $node) {
// Get max enrollment number.
$max = $node
->get('field_event_max_enroll_num')->value;
// Take into account AN enrollments.
$current = $this
->getEnrollmentsNumber($node);
// Count how many spots are left, but never display less than 0.
return $max >= $current ? $max - $current : 0;
}