ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilCertificateTemplateExportAction Class Reference
+ Collaboration diagram for ilCertificateTemplateExportAction:

Public Member Functions

 __construct (private readonly int $objectId, private readonly string $certificatePath, private readonly ilCertificateTemplateRepository $templateRepository, private readonly Filesystem $filesystem, ?ilCertificateObjectHelper $objectHelper=null, ?ilCertificateUtilHelper $utilHelper=null)
 
 export (string $rootDir=CLIENT_WEB_DIR, string $installationId=IL_INST_ID)
 Creates a downloadable file via the browser. More...
 

Private Attributes

readonly ilCertificateObjectHelper $objectHelper
 
readonly ilCertificateUtilHelper $utilHelper
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCertificateTemplateExportAction::__construct ( private readonly int  $objectId,
private readonly string  $certificatePath,
private readonly ilCertificateTemplateRepository  $templateRepository,
private readonly Filesystem  $filesystem,
?ilCertificateObjectHelper  $objectHelper = null,
?ilCertificateUtilHelper  $utilHelper = null 
)

Definition at line 35 of file class.ilCertificateTemplateExportAction.php.

References $objectHelper, and $utilHelper.

42  {
43  if (null === $objectHelper) {
45  }
46  $this->objectHelper = $objectHelper;
47 
48  if (null === $utilHelper) {
50  }
51  $this->utilHelper = $utilHelper;
52  }
Just a wrapper class to create Unit Test for other classes.

Member Function Documentation

◆ export()

ilCertificateTemplateExportAction::export ( string  $rootDir = CLIENT_WEB_DIR,
string  $installationId = IL_INST_ID 
)

Creates a downloadable file via the browser.

Exceptions
FileAlreadyExistsException
FileNotFoundException
IOException

Definition at line 60 of file class.ilCertificateTemplateExportAction.php.

References ILIAS\Repository\filesystem().

60  : void
61  {
62  $time = time();
63 
64  $type = $this->objectHelper->lookupType($this->objectId);
65  $certificateId = $this->objectId;
66 
67  $exportPath = $this->certificatePath . $time . '__' . $installationId . '__' . $type . '__' . $certificateId . '__certificate/';
68 
69  $streams = [];
70 
71  $template = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
72 
73  $streams['certificate.xml'] = Streams::ofString(
74  $template->getCertificateContent()
75  );
76 
77  $backgroundImagePath = $template->getBackgroundImagePath();
78  if ($backgroundImagePath !== '' && $this->filesystem->has($backgroundImagePath)) {
79  $streams['background.jpg'] = $this->filesystem->readStream($backgroundImagePath);
80  }
81 
82  $thumbnailImagePath = $template->getThumbnailImagePath();
83  if ($thumbnailImagePath !== '' && $this->filesystem->has($backgroundImagePath)) {
84  $streams['thumbnail.svg'] = $this->filesystem->readStream($thumbnailImagePath);
85  }
86 
87  $objectType = $this->objectHelper->lookupType($this->objectId);
88 
89  $zipFileName = $time . '__' . $installationId . '__' . $objectType . '__' . $this->objectId . '__certificate.zip';
90 
91  $this->utilHelper->zipAndDeliver($streams, $zipFileName);
92  }
+ Here is the call graph for this function:

Field Documentation

◆ $objectHelper

readonly ilCertificateObjectHelper ilCertificateTemplateExportAction::$objectHelper
private

Definition at line 32 of file class.ilCertificateTemplateExportAction.php.

Referenced by __construct().

◆ $utilHelper

readonly ilCertificateUtilHelper ilCertificateTemplateExportAction::$utilHelper
private

Definition at line 33 of file class.ilCertificateTemplateExportAction.php.

Referenced by __construct().


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