ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilCertificateTemplateDeleteAction.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 {
30 
31  public function __construct(
32  private readonly ilCertificateTemplateRepository $templateRepository,
33  private readonly string $rootDirectory = CLIENT_WEB_DIR,
34  private readonly string $iliasVersion = ILIAS_VERSION_NUMERIC,
35  ?ilCertificateUtilHelper $utilHelper = null,
36  ?ilCertificateObjectHelper $objectHelper = null
37  ) {
38  if (null === $utilHelper) {
39  $utilHelper = new ilCertificateUtilHelper();
40  }
41  $this->utilHelper = $utilHelper;
42 
43  if (null === $objectHelper) {
44  $objectHelper = new ilCertificateObjectHelper();
45  }
46  $this->objectHelper = $objectHelper;
47  }
48 
49  public function delete(int $templateId, int $objectId): void
50  {
51  $template = $this->templateRepository->fetchCurrentlyUsedCertificate($objectId);
52 
53  $this->templateRepository->deleteTemplate($templateId, $objectId);
54 
55  $version = $template->getVersion();
56  $certificateTemplate = new ilCertificateTemplate(
57  $objectId,
58  $this->objectHelper->lookupType($objectId),
59  '',
60  hash('sha256', ''),
61  '',
62  ($version + 1),
63  $this->iliasVersion,
64  time(),
65  false,
66  '',
67  ''
68  );
69 
70  $this->templateRepository->save($certificateTemplate);
71  }
72 }
const ILIAS_VERSION_NUMERIC
__construct(private readonly ilCertificateTemplateRepository $templateRepository, private readonly string $rootDirectory=CLIENT_WEB_DIR, private readonly string $iliasVersion=ILIAS_VERSION_NUMERIC, ?ilCertificateUtilHelper $utilHelper=null, ?ilCertificateObjectHelper $objectHelper=null)
const CLIENT_WEB_DIR
Definition: constants.php:47
Just a wrapper class to create Unit Test for other classes.
$version
Definition: plugin.php:24