ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilObjCertificateSettings.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23use ILIAS\ResourceStorage\Services as ResourceStorage;
27
35{
37 private readonly ResourceStorage $irss;
40
41 public function __construct(int $a_id = 0, bool $a_reference = true)
42 {
43 global $DIC;
44
45 parent::__construct($a_id, $a_reference);
46 $this->type = 'cert';
47 $this->certificate_settings = new ilSetting('certificate');
48 $this->irss = $DIC->resourceStorage();
49 $this->stakeholder = new ilCertificateTemplateStakeholder();
50 $this->resource_handler = new CertificateResourceHandler(
51 new ilUserCertificateRepository($DIC->database()),
53 $this->irss,
54 $this,
55 $this->stakeholder
56 );
57 }
58
60 {
61 $id = $this->certificate_settings->get('cert_bg_image', '');
62
63 if ($rid = $this->irss->manage()->find($id)) {
64 return $rid;
65 }
66 return null;
67 }
68
69 public function getBackgroundImageDefaultFolder(): string
70 {
71 return '/certificates/default/';
72 }
73
80 public function uploadBackgroundImage(UploadResult $upload_result): bool
81 {
82 $identification = $this->irss->manage()->upload($upload_result, $this->stakeholder);
83 $this->certificate_settings->set('cert_bg_image', $identification->serialize());
84
85 return $identification->serialize() !== '';
86 }
87
88 public function deleteBackgroundImage(): bool
89 {
91 if ($rid instanceof ResourceIdentification) {
92 $this->certificate_settings->set('cert_bg_image', '');
93 $this->resource_handler->handleResourceChange($rid);
94
95 return true;
96 }
97
98 return false;
99 }
100
101 public function hasBackgroundImage(): bool
102 {
103 return (bool) $this->certificate_settings->get('cert_bg_image', '');
104 }
105}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class ilObjCertificateSettings.
readonly CertificateResourceHandler $resource_handler
readonly ilCertificateTemplateStakeholder $stakeholder
uploadBackgroundImage(UploadResult $upload_result)
Uploads a background image for the certificate.
__construct(int $a_id=0, bool $a_reference=true)
Class ilObject Basic functions for all objects.
ILIAS Setting Class.
The filesystem interface provides the public interface for the Filesystem service API consumer.
Definition: Filesystem.php:37
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26