ILIAS  release_7 Revision v7.30-3-g800a261c036
ilCertificateBackgroundImageFileService.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8{
9 const BACKGROUND_IMAGE_NAME = 'background.jpg';
10 const BACKGROUND_TEMPORARY_UPLOAD_FILE_NAME = 'background_upload.tmp';
12 const PLACEHOLDER_CLIENT_WEB_DIRECTORY = '[CLIENT_WEB_DIR]';
13
17 private $fileSystem;
18
23
28
34 public function __construct(
35 string $certificatePath,
36 \ILIAS\Filesystem\Filesystem $filesystem,
38 ) {
39 $this->certificatePath = $certificatePath;
40 $this->fileSystem = $filesystem;
41 $this->webDirectory = $webDirectory;
42 }
43
49 public function hasBackgroundImage(ilCertificateTemplate $template)
50 {
51 $backgroundImagePath = $template->getBackgroundImagePath();
52 if ($backgroundImagePath === '') {
53 return false;
54 }
55
56 if ($this->fileSystem->has($backgroundImagePath)) {
57 return true;
58 }
59
60 return false;
61 }
62
68 {
69 $backgroundImagePath = $template->getThumbnailImagePath();
70 if ($backgroundImagePath === '') {
71 return false;
72 }
73
74 if ($this->fileSystem->has($backgroundImagePath)) {
75 return true;
76 }
77
78 return false;
79 }
80
86 {
87 return $this->webDirectory . $this->certificatePath . self::BACKGROUND_IMAGE_NAME . self::BACKGROUND_THUMBNAIL_FILE_ENDING;
88 }
89
95 public function getBackgroundImageDirectory($backgroundImagePath = '')
96 {
97 return str_replace(
98 array($this->webDirectory, '//'),
99 array(self::PLACEHOLDER_CLIENT_WEB_DIRECTORY, '/'),
100 $backgroundImagePath
101 );
102 }
103
110 {
111 return $this->webDirectory . $this->certificatePath . self::BACKGROUND_TEMPORARY_UPLOAD_FILE_NAME;
112 }
113}
An exception for terminatinating execution or to throw for unit testing.
getBackgroundImageTempfilePath()
Returns the filesystem path of the background image temp file during upload.
__construct(string $certificatePath, \ILIAS\Filesystem\Filesystem $filesystem, $webDirectory=CLIENT_WEB_DIR)
getBackgroundImageDirectory($backgroundImagePath='')
Returns the filesystem path of the background image.
getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
hasBackgroundImage(ilCertificateTemplate $template)
Checks for the background image of the certificate.
const CLIENT_WEB_DIR
Definition: constants.php:45
Class FlySystemFileAccessTest \Provider\FlySystem @runTestsInSeparateProcesses @preserveGlobalState d...
Class ChatMainBarProvider \MainMenu\Provider.