ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateVerificationFileService Class Reference
+ Collaboration diagram for ilCertificateVerificationFileService:

Public Member Functions

 __construct (ilLanguage $language, ilDBInterface $database, ilLogger $logger, ilCertificateVerificationClassMap $classMap)
 
 createFile (ilUserCertificatePresentation $userCertificatePresentation)
 
 initStorage (int $objectId, string $subDirectory='')
 

Private Attributes

 $language
 
 $database
 
 $logger
 
 $classMap
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ createFile()

ilCertificateVerificationFileService::createFile ( ilUserCertificatePresentation  $userCertificatePresentation)

Definition at line 47 of file class.ilCertificateVerificationFileService.php.

References $path, ilCertificatePdfAction\createPDF(), ilUserCertificatePresentation\getObjectDescription(), ilUserCertificatePresentation\getObjectTitle(), ilUserCertificatePresentation\getUserCertificate(), IL_CAL_UNIX, and initStorage().

Referenced by ilObjExerciseVerificationGUI\save(), ilObjTestVerificationGUI\save(), ilObjSCORMVerificationGUI\save(), and ilObjCourseVerificationGUI\save().

48  {
49  $userCertificate = $userCertificatePresentation->getUserCertificate();
50  $objectType = $userCertificate->getObjType();
51 
52  $this->language->loadLanguageModule('cert');
53 
54  $verificationObjectType = $this->classMap->getVerificationTypeByType($objectType);
55 
56  $verificationObject = new ilCertificateVerificationObject($verificationObjectType);
57  $verificationObject->setTitle($userCertificatePresentation->getObjectTitle());
58  $verificationObject->setDescription($userCertificatePresentation->getObjectDescription());
59 
60  $objectId = $userCertificate->getObjId();
61  $userId = $userCertificate->getUserId();
62 
63  $issueDate = new ilDate($userCertificate->getAcquiredTimestamp(), IL_CAL_UNIX);
64 
65  $verificationObject->setProperty('issued_on', $issueDate);
66 
67  $ilUserCertificateRepository = new ilUserCertificateRepository($this->database, $this->logger);
68  $pdfGenerator = new ilPdfGenerator($ilUserCertificateRepository, $this->logger);
69 
70  $pdfAction = new ilCertificatePdfAction(
71  $this->logger,
72  $pdfGenerator,
74  $this->language->txt('error_creating_certificate_pdf')
75  );
76 
77  $certificateScalar = $pdfAction->createPDF($userId, $objectId);
78 
79  if ($certificateScalar) {
80  // we need the object id for storing the certificate file
81  $verificationObject->create();
82 
83  $path = $this->initStorage($verificationObject->getId(), 'certificate');
84 
85  $fileName = $objectType . '_' . $objectId . '_' . $userId . '.pdf';
86 
87  if (file_put_contents($path . $fileName, $certificateScalar)) {
88  $verificationObject->setProperty('file', $fileName);
89  $verificationObject->update();
90 
91  return $verificationObject;
92  }
93 
94  $this->logger->info('File could not be created');
95  $verificationObject->delete();
96  }
97  }
Class ilPdfGeneratorConstantsTest.
$path
Definition: aliased.php:25
const IL_CAL_UNIX
Class for single dates.
Just a wrapper class to create Unit Test for other classes.
createPDF(int $userId, int $objectId)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initStorage()

ilCertificateVerificationFileService::initStorage ( int  $objectId,
string  $subDirectory = '' 
)
Parameters
int$objectId
string$subDirectory
Returns
string

Definition at line 104 of file class.ilCertificateVerificationFileService.php.

References $path.

Referenced by createFile().

105  {
106  $storage = new ilVerificationStorageFile($objectId);
107  $storage->create();
108 
109  $path = $storage->getAbsolutePath() . "/";
110 
111  if ($subDirectory !== '') {
112  $path .= $subDirectory . "/";
113 
114  if (!is_dir($path)) {
115  mkdir($path);
116  }
117  }
118 
119  return $path;
120  }
$path
Definition: aliased.php:25
+ Here is the caller graph for this function:

Field Documentation

◆ $classMap

ilCertificateVerificationFileService::$classMap
private

Definition at line 27 of file class.ilCertificateVerificationFileService.php.

Referenced by __construct().

◆ $database

ilCertificateVerificationFileService::$database
private

Definition at line 17 of file class.ilCertificateVerificationFileService.php.

Referenced by __construct().

◆ $language

ilCertificateVerificationFileService::$language
private

Definition at line 12 of file class.ilCertificateVerificationFileService.php.

Referenced by __construct().

◆ $logger

ilCertificateVerificationFileService::$logger
private

Definition at line 22 of file class.ilCertificateVerificationFileService.php.

Referenced by __construct().


The documentation for this class was generated from the following file: