Example #1
0
 /**
  * Issue the CVI for the given event (recording it as an action performed by the given user id).
  *
  * @param \Event $event
  * @param $user_id
  * @return bool
  */
 public function issueCvi(\Event $event, $user_id)
 {
     // begin transaction
     $transaction = $this->startTransaction();
     try {
         $event->lock();
         $cvi_certificate = $this->generateCviCertificate($event);
         // set the status of the event to complete and assign the PDF to the event
         $info_element = $this->getEventInfoElementForEvent($event);
         $info_element->is_draft = false;
         $info_element->generated_document_id = $cvi_certificate->id;
         $info_element->save();
         $event->info = $this->getStatusText(self::$ISSUED);
         $event->save();
         $event->audit('event', 'cvi-issued', null, 'CVI Issued', array('user_id' => $user_id));
         $transaction->commit();
         $event->unlock();
         return true;
     } catch (\Exception $e) {
         \OELog::log($e->getMessage());
         $transaction->rollback();
     }
     return false;
 }