ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilCertificateTemplateDeleteAction.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
27 
28  public function __construct(
29  private readonly ilCertificateTemplateRepository $templateRepository,
30  private readonly string $iliasVersion = ILIAS_VERSION_NUMERIC,
31  ?ilCertificateObjectHelper $objectHelper = null
32  ) {
33  if (null === $objectHelper) {
34  $objectHelper = new ilCertificateObjectHelper();
35  }
36  $this->objectHelper = $objectHelper;
37  }
38 
39  public function delete(int $templateId, int $objectId): void
40  {
41  $template = $this->templateRepository->fetchCurrentlyUsedCertificate($objectId);
42 
43  $this->templateRepository->deleteTemplate($templateId, $objectId);
44 
45  $version = $template->getVersion();
46  $certificateTemplate = new ilCertificateTemplate(
47  $objectId,
48  $this->objectHelper->lookupType($objectId),
49  '',
50  hash('sha256', ''),
51  '',
52  $version + 1,
53  $this->iliasVersion,
54  time(),
55  false,
56  '',
57  '',
58  '',
59  '',
60  );
61 
62  $this->templateRepository->save($certificateTemplate);
63  }
64 }
$version
Definition: plugin.php:24
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const ILIAS_VERSION_NUMERIC
__construct(private readonly ilCertificateTemplateRepository $templateRepository, private readonly string $iliasVersion=ILIAS_VERSION_NUMERIC, ?ilCertificateObjectHelper $objectHelper=null)