19 declare(strict_types=1);
50 string $global_certificate_path = null
56 if (null === $logger) {
58 $logger = $DIC->logger()->cert();
62 if (null === $fileSystem) {
64 $fileSystem = $DIC->filesystem()->web();
68 if (null === $objectHelper) {
73 if (!$global_certificate_settings) {
78 if (null === $global_certificate_path) {
98 public function cloneCertificate(
104 $oldType = $oldObject->
getType();
105 $newType = $newObject->
getType();
107 if ($oldType !== $newType) {
109 'The types "%s" and "%s" for cloning does not match',
115 $certificatePath = $this->pathFactory->create($newObject);
117 $templates = $this->templateRepository->fetchCertificateTemplatesByObjId($oldObject->
getId());
120 foreach ($templates as $template) {
121 $backgroundImagePath = $template->getBackgroundImagePath();
122 $backgroundImageFile = basename($backgroundImagePath);
123 $backgroundImageThumbnail = dirname($backgroundImagePath) .
'/background.jpg.thumb.jpg';
125 $newBackgroundImage =
'';
126 $newBackgroundImageThumbnail =
'';
127 if ($this->global_certificate_path !== $backgroundImagePath) {
128 if ($this->fileSystem->has($backgroundImagePath) &&
129 !$this->fileSystem->hasDir($backgroundImagePath)
131 $newBackgroundImage = $certificatePath . $backgroundImageFile;
132 $newBackgroundImageThumbnail = str_replace(
137 if ($this->fileSystem->has($newBackgroundImage) &&
138 !$this->fileSystem->hasDir($newBackgroundImage)
140 $this->fileSystem->delete($newBackgroundImage);
143 $this->fileSystem->copy(
144 $backgroundImagePath,
150 $newBackgroundImageThumbnail !==
'' &&
151 $this->fileSystem->has($backgroundImageThumbnail) &&
152 !$this->fileSystem->hasDir($backgroundImageThumbnail)
154 if ($this->fileSystem->has($newBackgroundImageThumbnail) &&
155 !$this->fileSystem->hasDir($newBackgroundImageThumbnail)
157 $this->fileSystem->delete($newBackgroundImageThumbnail);
160 $this->fileSystem->copy(
161 $backgroundImageThumbnail,
162 $newBackgroundImageThumbnail
169 $newCardThumbImage =
'';
170 $cardThumbImagePath = $template->getThumbnailImagePath();
172 if ($this->fileSystem->has($cardThumbImagePath) && !$this->fileSystem->hasDir($cardThumbImagePath)) {
173 $newCardThumbImage = $certificatePath . basename($cardThumbImagePath);
174 if ($this->fileSystem->has($newCardThumbImage) && !$this->fileSystem->hasDir($newCardThumbImage)) {
175 $this->fileSystem->delete($newCardThumbImage);
177 $this->fileSystem->copy(
185 $this->objectHelper->lookupType($newObject->
getId()),
186 $template->getCertificateContent(),
187 $template->getCertificateHash(),
188 $template->getTemplateValues(),
189 $template->getVersion(),
192 $template->isCurrentlyActive(),
197 $this->templateRepository->save($newTemplate);
202 $this->database->replace(
204 [
'obj_id' => [
'integer', $newObject->
getId()]],
212 $sql =
'SELECT 1 FROM il_certificate WHERE obj_id = ' . $this->database->quote($objectId,
'integer');
214 if ($row = $this->database->fetchAssoc($this->database->query($sql))) {
223 return "background.jpg";
__construct(ilDBInterface $database, ilCertificatePathFactory $pathFactory, ilCertificateTemplateRepository $templateRepository, ?Filesystem $fileSystem=null, ?ilLogger $logger=null, ?ilCertificateObjectHelper $objectHelper=null, ?ilObjCertificateSettings $global_certificate_settings=null, string $webDirectory=CLIENT_WEB_DIR, string $global_certificate_path=null)
const ILIAS_VERSION_NUMERIC
ilCertificatePathFactory $pathFactory
Class ilObjCertificateSettings.
ilCertificateTemplateRepository $templateRepository
string $global_certificate_path
getDefaultBackgroundImagePath(bool $relativePath=false)
getBackgroundImageThumbPath(string $certificatePath)
ilCertificateObjectHelper $objectHelper
ilObjCertificateSettings $global_certificate_settings
Class FlySystemFileAccessTest disabled disabled disabled.