Skip to content
Snippets Groups Projects

add AttendanceCertificateEvent symfony event

3 files
+ 108
0
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -2,6 +2,7 @@
use Civi\Api4\Participant;
use Civi\Certificates\PDFCertificate;
use Civi\Certificates\Event\AttendanceCertificateEvent;
class CRM_Certificates_Form_Task extends CRM_Contact_Form_Task {
@@ -26,6 +27,10 @@ class CRM_Certificates_Form_Task extends CRM_Contact_Form_Task {
$context[] = ['contactId' => $participant['contact_id.id'], 'participantId' => $participantID, 'eventId' => $participant['event_id.id']];
$messageTemplateID = \Civi::settings()->get('certificates_event_defaultmessagetemplateid');
$attendanceEvent = new AttendanceCertificateEvent( $participantID, $participant['contact_id.id'], $participant['event_id.id'], $messageTemplateID);
\Civi::dispatcher()->dispatch('civi.certificates.attendance', $attendanceEvent);
$messageTemplateID = $attendanceEvent->getMessageTemplateId();
if (empty($messageTemplateID)) {
\Civi::log()->error('Event attendance certificate has no message template ID set!');
throw new \CRM_Core_Exception('Attendance certificate generation disabled.');
Loading