ILIAS  release_8 Revision v8.24
ilCertificateTemplateExportAction Class Reference
+ Collaboration diagram for ilCertificateTemplateExportAction:

Public Member Functions

 __construct (int $objectId, string $certificatePath, ilCertificateTemplateRepository $templateRepository, 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

int $objectId
 
string $certificatePath
 
ilCertificateTemplateRepository $templateRepository
 
Filesystem $filesystem
 
ilCertificateObjectHelper $objectHelper
 
ilCertificateUtilHelper $utilHelper
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

45 {
46 $this->objectId = $objectId;
47 $this->certificatePath = $certificatePath;
48 $this->templateRepository = $templateRepository;
49 $this->filesystem = $filesystem;
50
51 if (null === $objectHelper) {
53 }
54 $this->objectHelper = $objectHelper;
55
56 if (null === $utilHelper) {
58 }
59 $this->utilHelper = $utilHelper;
60 }
Just a wrapper class to create Unit Test for other classes.

References $certificatePath, $filesystem, $objectHelper, $objectId, $templateRepository, $utilHelper, and ILIAS\Repository\filesystem().

+ Here is the call graph for this function:

Member Function Documentation

◆ export()

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

Creates a downloadable file via the browser.

Parameters
string$rootDir
string$installationId
Exceptions
FileAlreadyExistsException
FileNotFoundException
IOException

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

70 : void
71 {
72 $time = time();
73
74 $type = $this->objectHelper->lookupType($this->objectId);
75 $certificateId = $this->objectId;
76
77 $exportPath = $this->certificatePath . $time . '__' . $installationId . '__' . $type . '__' . $certificateId . '__certificate/';
78
79 $this->filesystem->createDir($exportPath);
80
81 $template = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
82
83 $xslContent = $template->getCertificateContent();
84
85 $this->filesystem->put($exportPath . 'certificate.xml', $xslContent);
86
87 $backgroundImagePath = $template->getBackgroundImagePath();
88 if ($backgroundImagePath !== '' && true === $this->filesystem->has($backgroundImagePath)) {
89 $this->filesystem->copy($backgroundImagePath, $exportPath . 'background.jpg');
90 }
91
92 $thumbnailImagePath = $template->getThumbnailImagePath();
93 if ($thumbnailImagePath !== '' && true === $this->filesystem->has($backgroundImagePath)) {
94 $this->filesystem->copy($thumbnailImagePath, $exportPath . 'thumbnail.svg');
95 }
96
97 $objectType = $this->objectHelper->lookupType($this->objectId);
98
99 $zipFileName = $time . '__' . $installationId . '__' . $objectType . '__' . $this->objectId . '__certificate.zip';
100
101 $zipPath = $rootDir . $this->certificatePath . $zipFileName;
102 $this->utilHelper->zip($exportPath, $zipPath);
103 $this->filesystem->deleteDir($exportPath);
104
105 $this->utilHelper->deliverFile($zipPath, $zipFileName, 'application/zip');
106 }
$type

References $objectId, $type, and ILIAS\Repository\filesystem().

+ Here is the call graph for this function:

Field Documentation

◆ $certificatePath

string ilCertificateTemplateExportAction::$certificatePath
private

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

Referenced by __construct().

◆ $filesystem

Filesystem ilCertificateTemplateExportAction::$filesystem
private

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

Referenced by __construct().

◆ $objectHelper

ilCertificateObjectHelper ilCertificateTemplateExportAction::$objectHelper
private

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

Referenced by __construct().

◆ $objectId

int ilCertificateTemplateExportAction::$objectId
private

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

Referenced by __construct(), and export().

◆ $templateRepository

ilCertificateTemplateRepository ilCertificateTemplateExportAction::$templateRepository
private

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

Referenced by __construct().

◆ $utilHelper

ilCertificateUtilHelper ilCertificateTemplateExportAction::$utilHelper
private

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

Referenced by __construct().


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