ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilCertificateTemplateExportAction.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 
32 {
35 
36  public function __construct(
37  private readonly int $objectId,
38  private readonly string $certificatePath,
39  private readonly ilCertificateTemplateRepository $templateRepository,
40  private readonly IRSS $irss,
41  ?ilCertificateObjectHelper $objectHelper = null,
42  ?ilCertificateUtilHelper $utilHelper = null
43  ) {
44  if (null === $objectHelper) {
45  $objectHelper = new ilCertificateObjectHelper();
46  }
47  $this->objectHelper = $objectHelper;
48 
49  if (null === $utilHelper) {
50  $utilHelper = new ilCertificateUtilHelper();
51  }
52  $this->utilHelper = $utilHelper;
53  }
54 
58  public function export(string $rootDir = CLIENT_WEB_DIR, string $installationId = IL_INST_ID): void
59  {
60  $time = time();
61 
62  $type = $this->objectHelper->lookupType($this->objectId);
63  $certificateId = $this->objectId;
64 
65  $exportPath = $this->certificatePath . $time . '__' . $installationId . '__' . $type . '__' . $certificateId . '__certificate/';
66 
67  $streams = [];
68 
69  $template = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
70 
71  $streams['certificate.xml'] = Streams::ofString(
72  $template->getCertificateContent()
73  );
74 
75  $background_rid = $this->irss->manage()->find($template->getBackgroundImageIdentification());
76  if ($background_rid instanceof ResourceIdentification) {
77  $streams['background.jpg'] = $this->irss->consume()->stream($background_rid)->getStream();
78  }
79 
80  $tile_image_rid = $this->irss->manage()->find($template->getTileImageIdentification());
81  if ($tile_image_rid instanceof ResourceIdentification) {
82  $streams['tile_image.svg'] = $this->irss->consume()->stream($tile_image_rid)->getStream();
83  }
84 
85  $objectType = $this->objectHelper->lookupType($this->objectId);
86 
87  $zipFileName = $time . '__' . $installationId . '__' . $objectType . '__' . $this->objectId . '__certificate.zip';
88 
89  $this->utilHelper->zipAndDeliver($streams, $zipFileName);
90  }
91 }
const IL_INST_ID
Definition: constants.php:40
export(string $rootDir=CLIENT_WEB_DIR, string $installationId=IL_INST_ID)
Creates a downloadable file via the browser.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CLIENT_WEB_DIR
Definition: constants.php:47
__construct(private readonly int $objectId, private readonly string $certificatePath, private readonly ilCertificateTemplateRepository $templateRepository, private readonly IRSS $irss, ?ilCertificateObjectHelper $objectHelper=null, ?ilCertificateUtilHelper $utilHelper=null)