ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ($rootDir=CLIENT_WEB_DIR, $installationId=IL_INST_ID)
 Creates an downloadable file via the browser. More...
 

Private Attributes

 $objectId
 
 $certificatePath
 
 $templateRepository
 
 $filesystem
 
 $objectHelper
 
 $utilHelper
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References $certificatePath, $filesystem, $objectHelper, $objectId, $templateRepository, and $utilHelper.

56  {
57  $this->objectId = $objectId;
58  $this->certificatePath = $certificatePath;
59  $this->templateRepository = $templateRepository;
60  $this->filesystem = $filesystem;
61 
62  if (null === $objectHelper) {
63  $objectHelper = new ilCertificateObjectHelper();
64  }
65  $this->objectHelper = $objectHelper;
66 
67  if (null === $utilHelper) {
68  $utilHelper = new ilCertificateUtilHelper();
69  }
70  $this->utilHelper = $utilHelper;
71  }
Just a wrapper class to create Unit Test for other classes.

Member Function Documentation

◆ export()

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

Creates an downloadable file via the browser.

Parameters
string$rootDir
string$installationId
Exceptions

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

References $objectId, $template, $time, and $type.

82  {
83  $time = time();
84 
85  $type = $this->objectHelper->lookupType($this->objectId);
86  $certificateId = $this->objectId;
87 
88  $exportPath = $this->certificatePath . $time . '__' . $installationId . '__' . $type . '__' . $certificateId . '__certificate/';
89 
90  $this->filesystem->createDir($exportPath, \ILIAS\Filesystem\Visibility::PUBLIC_ACCESS);
91 
92  $template = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
93 
94  $xslContent = $template->getCertificateContent();
95 
96  $this->filesystem->put($exportPath . 'certificate.xml', $xslContent);
97 
98  $backgroundImagePath = $template->getBackgroundImagePath();
99  if ($backgroundImagePath !== '') {
100  if (true === $this->filesystem->has($backgroundImagePath)) {
101  $this->filesystem->copy($backgroundImagePath, $exportPath . 'background.jpg');
102  }
103  }
104 
105  $thumbnailImagePath = $template->getThumbnailImagePath();
106  if ($thumbnailImagePath !== '') {
107  if (true === $this->filesystem->has($backgroundImagePath)) {
108  $this->filesystem->copy($thumbnailImagePath, $exportPath . 'thumbnail.svg');
109  }
110  }
111 
112  $objectType = $this->objectHelper->lookupType($this->objectId);
113 
114  $zipFileName = $time . '__' . $installationId . '__' . $objectType . '__' . $this->objectId . '__certificate.zip';
115 
116 
117  $zipPath = $rootDir . $this->certificatePath . $zipFileName;
118  $this->utilHelper->zip($exportPath, $zipPath);
119  $this->filesystem->deleteDir($exportPath);
120 
121  $this->utilHelper->deliverFile($zipPath, $zipFileName, 'application/zip');
122  }
$template
$type
Class BaseForm.
$time
Definition: cron.php:21
Class FlySystemFileAccessTest.

Field Documentation

◆ $certificatePath

ilCertificateTemplateExportAction::$certificatePath
private

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

Referenced by __construct().

◆ $filesystem

ilCertificateTemplateExportAction::$filesystem
private

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

Referenced by __construct().

◆ $objectHelper

ilCertificateTemplateExportAction::$objectHelper
private

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

Referenced by __construct().

◆ $objectId

ilCertificateTemplateExportAction::$objectId
private

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

Referenced by __construct(), and export().

◆ $templateRepository

ilCertificateTemplateExportAction::$templateRepository
private

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

Referenced by __construct().

◆ $utilHelper

ilCertificateTemplateExportAction::$utilHelper
private

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

Referenced by __construct().


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