protected function WebformCivicrmBase::loadEvents in Webform CiviCRM Integration 8.5
Fetch info and remaining spaces for events
2 calls to WebformCivicrmBase::loadEvents()
- WebformCivicrmPostProcess::validateParticipants in src/
WebformCivicrmPostProcess.php - Validate event participants and add line items
- WebformCivicrmPreProcess::populateEvents in src/
WebformCivicrmPreProcess.php - Check if events are open to registration and take appropriate action
File
- src/
WebformCivicrmBase.php, line 629 - Front-end form handler base class.
Class
- WebformCivicrmBase
- Class WebformCivicrmBase
Namespace
Drupal\webform_civicrmCode
protected function loadEvents() {
$utils = \Drupal::service('webform_civicrm.utils');
if (!empty($this->events)) {
$now = time();
$events = $utils
->wf_crm_apivalues('Event', 'get', [
'return' => [
'title',
'start_date',
'end_date',
'event_type_id',
'max_participants',
'financial_type_id',
'event_full_text',
'is_full',
],
'id' => [
'IN' => array_keys($this->events),
],
]);
foreach ($events as $id => $event) {
$this->events[$id] = $event + $this->events[$id] + [
'available_places' => 0,
];
$this->events[$id]['ended'] = !empty($event['end_date']) && strtotime($event['end_date']) < $now;
}
}
}