ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateTemplateDeleteAction Class Reference
+ Inheritance diagram for ilCertificateTemplateDeleteAction:
+ Collaboration diagram for ilCertificateTemplateDeleteAction:

Public Member Functions

 __construct (ilCertificateTemplateRepository $templateRepository, string $rootDirectory=CLIENT_WEB_DIR, ilCertificateUtilHelper $utilHelper=null, ilCertificateObjectHelper $objectHelper=null, $iliasVersion=ILIAS_VERSION_NUMERIC)
 
 delete ($templateTemplateId, $objectId)
 

Private Member Functions

 overwriteBackgroundImageThumbnail (ilCertificateTemplate $previousTemplate)
 

Private Attributes

 $templateRepository
 
 $rootDirectory
 
 $utilHelper
 
 $objectHelper
 
 $iliasVersion
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCertificateTemplateDeleteAction::__construct ( ilCertificateTemplateRepository  $templateRepository,
string  $rootDirectory = CLIENT_WEB_DIR,
ilCertificateUtilHelper  $utilHelper = null,
ilCertificateObjectHelper  $objectHelper = null,
  $iliasVersion = ILIAS_VERSION_NUMERIC 
)
Parameters
ilCertificateTemplateRepository$templateRepository
string$rootDirectory
ilCertificateUtilHelper | null$utilHelper
ilCertificateObjectHelper | null$objectHelper
string$iliasVersion

Definition at line 41 of file class.ilCertificateTemplateDeleteAction.php.

References $iliasVersion, $objectHelper, $rootDirectory, $templateRepository, and $utilHelper.

47  {
48  $this->templateRepository = $templateRepository;
49 
50  $this->rootDirectory = $rootDirectory;
51 
52  if (null === $utilHelper) {
53  $utilHelper = new ilCertificateUtilHelper();
54  }
55  $this->utilHelper = $utilHelper;
56 
57  if (null === $objectHelper) {
58  $objectHelper = new ilCertificateObjectHelper();
59  }
60  $this->objectHelper = $objectHelper;
61 
62  $this->iliasVersion = $iliasVersion;
63  }
Just a wrapper class to create Unit Test for other classes.

Member Function Documentation

◆ delete()

ilCertificateTemplateDeleteAction::delete (   $templateTemplateId,
  $objectId 
)
Parameters
$templateTemplateId
$objectId
string$iliasVersion
Returns
mixed
Exceptions
ilDatabaseException

Implements ilCertificateDeleteAction.

Definition at line 72 of file class.ilCertificateTemplateDeleteAction.php.

References $iliasVersion, $template, $version, GuzzleHttp\Psr7\hash(), and overwriteBackgroundImageThumbnail().

73  {
74  $template = $this->templateRepository->fetchCurrentlyUsedCertificate($objectId);
75 
76  $this->templateRepository->deleteTemplate($templateTemplateId, $objectId);
77 
78  $version = (int) $template->getVersion();
79  $certificateTemplate = new ilCertificateTemplate(
80  $objectId,
81  $this->objectHelper->lookupType($objectId),
82  '',
83  hash('sha256', ''),
84  '',
85  $version + 1,
87  time(),
88  false,
89  '',
90  ''
91  );
92 
93  $this->templateRepository->save($certificateTemplate);
94 
95  $this->overwriteBackgroundImageThumbnail($certificateTemplate);
96  }
$template
$version
Definition: build.php:27
overwriteBackgroundImageThumbnail(ilCertificateTemplate $previousTemplate)
hash(StreamInterface $stream, $algo, $rawOutput=false)
Calculate a hash of a Stream.
Definition: functions.php:406
+ Here is the call graph for this function:

◆ overwriteBackgroundImageThumbnail()

ilCertificateTemplateDeleteAction::overwriteBackgroundImageThumbnail ( ilCertificateTemplate  $previousTemplate)
private
Parameters
$previousTemplate

Definition at line 101 of file class.ilCertificateTemplateDeleteAction.php.

References ilCertificateTemplate\getBackgroundImagePath().

Referenced by delete().

102  {
103  $relativePath = $previousTemplate->getBackgroundImagePath();
104 
105  if (null === $relativePath || '' === $relativePath) {
106  $relativePath = '/certificates/default/background.jpg';
107  }
108 
109  $pathInfo = pathinfo($relativePath);
110 
111  $newFilePath = $pathInfo['dirname'] . '/background.jpg.thumb.jpg';
112 
113  $this->utilHelper->convertImage(
114  $this->rootDirectory . $relativePath,
115  $this->rootDirectory . $newFilePath,
116  'JPEG',
117  100
118  );
119  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $iliasVersion

ilCertificateTemplateDeleteAction::$iliasVersion
private

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

Referenced by __construct(), and delete().

◆ $objectHelper

ilCertificateTemplateDeleteAction::$objectHelper
private

Definition at line 27 of file class.ilCertificateTemplateDeleteAction.php.

Referenced by __construct().

◆ $rootDirectory

ilCertificateTemplateDeleteAction::$rootDirectory
private

Definition at line 17 of file class.ilCertificateTemplateDeleteAction.php.

Referenced by __construct().

◆ $templateRepository

ilCertificateTemplateDeleteAction::$templateRepository
private

Definition at line 12 of file class.ilCertificateTemplateDeleteAction.php.

Referenced by __construct().

◆ $utilHelper

ilCertificateTemplateDeleteAction::$utilHelper
private

Definition at line 22 of file class.ilCertificateTemplateDeleteAction.php.

Referenced by __construct().


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