19 declare(strict_types=1);
39 private readonly
int $objectId,
40 private readonly
string $certificatePath,
44 private readonly
IRSS $irss,
51 if (
null === $database) {
52 $database = $DIC->database();
55 if (
null === $templateRepository) {
60 if (
null === $objectHelper) {
65 if (
null === $utilHelper) {
79 public function import(
88 $clean_up_import_dir =
function () use (&$importPath) {
94 $this->
logger->error(sprintf(
"Can't clean up import directory: %s", $e->getMessage()));
95 $this->
logger->error($e->getTraceAsString());
99 $result = $this->utilHelper->moveUploadedFile($zipFile, $filename, $rootDir . $importPath . $filename);
101 $clean_up_import_dir();
106 $destination_dir = $rootDir . $importPath;
107 $unzip = $this->utilHelper->unzip(
108 $rootDir . $importPath . $filename,
113 $unzipped = $unzip->extract();
119 $clean_up_import_dir();
124 if ($this->
filesystem->has($importPath . $filename)) {
125 $this->
filesystem->delete($importPath . $filename);
129 $contents = $this->
filesystem->listContents($importPath);
130 foreach ($contents as $file) {
131 if ($file->isFile() && str_contains($file->getPath(),
'.xml')) {
136 if (0 === $xmlFiles) {
140 $certificate = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
142 $currentVersion = $certificate->getVersion();
143 $newVersion = $currentVersion + 1;
144 $xsl = $certificate->getCertificateContent();
146 foreach ($contents as $file) {
147 if (!$file->isFile()) {
151 if (str_contains($file->getPath(),
'.xml')) {
152 $xsl = $this->
filesystem->read($file->getPath());
153 } elseif (str_contains($file->getPath(),
'.jpg')) {
154 $background_rid = $this->irss->manage()->stream(
155 $this->
filesystem->readStream($file->getPath()),
158 } elseif (str_contains($file->getPath(),
'.svg')) {
159 $tile_image_rid = $this->irss->manage()->stream(
160 $this->
filesystem->readStream($file->getPath()),
166 $jsonEncodedTemplateValues = json_encode(
167 $this->placeholderDescriptionObject->getPlaceholderDescriptions(),
171 $newHashValue =
hash(
175 isset($background_rid) ? $this->irss->manage()->getResource(
177 )->getStorageID() :
'',
178 $jsonEncodedTemplateValues,
179 isset($tile_image_rid) ? $this->irss->manage()->getResource(
181 )->getStorageID() :
'' 187 $this->objectHelper->lookupType($this->objectId),
190 $jsonEncodedTemplateValues,
197 isset($background_rid) ? $background_rid->serialize() :
'',
198 isset($tile_image_rid) ? $tile_image_rid->serialize() :
'' 201 $this->templateRepository->save($template);
203 $clean_up_import_dir();
215 $type = $this->objectHelper->lookupType($this->objectId);
216 $certificateId = $this->objectId;
218 $dir = $this->certificatePath . time() .
'__' . $installationID .
'__' . $type .
'__' . $certificateId .
'__certificate/';
readonly ilCertificateTemplateStakeholder $stakeholder
__construct(private readonly int $objectId, private readonly string $certificatePath, private readonly ilCertificatePlaceholderDescription $placeholderDescriptionObject, private readonly ilLogger $logger, private readonly Filesystem $filesystem, private readonly IRSS $irss, ?ilCertificateTemplateRepository $templateRepository=null, ?ilCertificateObjectHelper $objectHelper=null, ?ilCertificateUtilHelper $utilHelper=null, ?ilDBInterface $database=null,)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readonly ilCertificateObjectHelper $objectHelper
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
readonly ilCertificateUtilHelper $utilHelper
const ILIAS_VERSION_NUMERIC
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readonly ilCertificateTemplateRepository $templateRepository
createArchiveDirectory(string $installationID)
Creates a directory for a zip archive containing multiple certificates.