ILIAS  release_8 Revision v8.23
classs.ilCertificateBackgroundImageDelete.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
26  private string $certificatePath;
28 
29  public function __construct(string $certificatePath, ilCertificateBackgroundImageFileService $fileService)
30  {
31  $this->certificatePath = $certificatePath;
32  $this->fileService = $fileService;
33  }
34 
35  public function deleteBackgroundImage(?int $version): void
36  {
37  if (is_file($this->fileService->getBackgroundImageThumbPath())) {
38  unlink($this->fileService->getBackgroundImageThumbPath());
39  }
40 
41  $version_string = '';
42  if (is_int($version) && $version >= 0) {
43  $version_string = (string) $version;
44  }
45 
46  $filename = $this->certificatePath . 'background_' . $version_string . '.jpg';
47  if (is_file($filename)) {
48  unlink($filename);
49  }
50 
51  foreach ($this->fileService->getValidBackgroundImageFileExtensions() as $extension) {
52  if (file_exists($this->fileService->getBackgroundImageTempfilePath($extension))) {
53  unlink($this->fileService->getBackgroundImageTempfilePath($extension));
54  }
55  }
56  }
57 }
ilCertificateBackgroundImageFileService $fileService
__construct(string $certificatePath, ilCertificateBackgroundImageFileService $fileService)
$filename
Definition: buildRTE.php:78
$version
Definition: plugin.php:24