62 $logger = $DIC->logger()->cert();
88 public function cloneCertificate(
92 string $webDir = CLIENT_WEB_DIR
94 $oldType = $oldObject->
getType();
95 $newType = $newObject->
getType();
97 if ($oldType !== $newType) {
99 'The types "%s" and "%s" for cloning does not match',
105 $newCertificate = $this->certificateFactory->create($newObject);
107 $templates = $this->templateRepository->fetchCertificateTemplatesByObjId($oldObject->
getId());
111 $backgroundImagePath = $template->getBackgroundImagePath();
112 $backgroundImageFile = basename($backgroundImagePath);
113 $backgroundImageThumbnail = dirname($backgroundImagePath) .
'/background.jpg.thumb.jpg';
115 $newBackgroundImage =
'';
116 $newBackgroundImageThumbnail =
'';
118 if ($this->fileSystem->has($backgroundImagePath) &&
119 !$this->fileSystem->hasDir($backgroundImagePath)
121 $newBackgroundImage = $newCertificate->getBackgroundImageDirectory() . $backgroundImageFile;
122 $newBackgroundImageThumbnail = str_replace($webDir,
'', $newCertificate->getBackgroundImageThumbPath());
124 if ($this->fileSystem->has($newBackgroundImage) &&
125 !$this->fileSystem->hasDir($newBackgroundImage)
127 $this->fileSystem->delete($newBackgroundImage);
130 $this->fileSystem->copy(
131 $backgroundImagePath,
137 strlen($newBackgroundImageThumbnail) > 0 &&
138 $this->fileSystem->has($backgroundImageThumbnail) &&
139 !$this->fileSystem->hasDir($backgroundImageThumbnail)
141 if ($this->fileSystem->has($newBackgroundImageThumbnail) &&
142 !$this->fileSystem->hasDir($newBackgroundImageThumbnail)
144 $this->fileSystem->delete($newBackgroundImageThumbnail);
147 $this->fileSystem->copy(
148 $backgroundImageThumbnail,
149 $newBackgroundImageThumbnail
153 $newCardThumbImage =
'';
154 $cardThumbImagePath = $template->getThumbnailImagePath();
156 if ($this->fileSystem->has($cardThumbImagePath) && !$this->fileSystem->hasDir($cardThumbImagePath)) {
157 $newCardThumbImage = $newCertificate->getBackgroundImageDirectory() . basename($cardThumbImagePath);
158 if ($this->fileSystem->has($newCardThumbImage) && !$this->fileSystem->hasDir($newCardThumbImage)) {
159 $this->fileSystem->delete($newCardThumbImage);
161 $this->fileSystem->copy(
169 $this->objectHelper->lookupType($newObject->
getId()),
170 $template->getCertificateContent(),
171 $template->getCertificateHash(),
172 $template->getTemplateValues(),
173 $template->getVersion(),
176 $template->isCurrentlyActive(),
181 $this->templateRepository->save($newTemplate);
186 $this->database->replace(
188 array(
'obj_id' => array(
'integer', $newObject->
getId())),
200 $sql =
'SELECT obj_id FROM il_certificate WHERE obj_id = ' . $this->database->quote($objectId,
'integer');
202 $query = $this->database->query($sql);
204 return $this->database->numRows(
$query);
const ILIAS_VERSION_NUMERIC
__construct(ilDBInterface $database, ilCertificateFactory $certificateFactory, ilCertificateTemplateRepository $templateRepository, \ILIAS\Filesystem\Filesystem $fileSystem=null, ilLogger $logger=null, ilCertificateObjectHelper $objectHelper=null)
getId()
get object id public
getType()
get object type public
readActive(int $objectId)
Component logger with individual log levels by component id.
Class FlySystemFileAccessTest.