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();
createArchiveDirectory(string $installationID)
Creates a directory for a zip archive containing multiple certificates.