ILIAS  release_8 Revision v8.23
FilesystemFacade.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 namespace ILIAS\Filesystem;
6 
13 
14 /******************************************************************************
15  *
16  * This file is part of ILIAS, a powerful learning management system.
17  *
18  * ILIAS is licensed with the GPL-3.0, you should have received a copy
19  * of said license along with the source code.
20  *
21  * If this is not the case or you just want to try ILIAS, you'll find
22  * us at:
23  * https://www.ilias.de
24  * https://github.com/ILIAS-eLearning
25  *
26  *****************************************************************************/
41 final class FilesystemFacade implements Filesystem
42 {
46 
47 
57  public function __construct(FileStreamAccess $fileStreamAccess, FileAccess $fileAccess, DirectoryAccess $directoryAccess)
58  {
59  $this->fileStreamAccess = $fileStreamAccess;
60  $this->fileAccess = $fileAccess;
61  $this->directoryAccess = $directoryAccess;
62  }
63 
64 
68  public function hasDir(string $path): bool
69  {
70  return $this->directoryAccess->hasDir($path);
71  }
72 
73 
77  public function listContents(string $path = '', bool $recursive = false): array
78  {
79  return $this->directoryAccess->listContents($path, $recursive);
80  }
81 
82 
86  public function createDir(string $path, string $visibility = Visibility::PUBLIC_ACCESS): void
87  {
88  $this->directoryAccess->createDir($path, $visibility);
89  }
90 
91 
95  public function copyDir(string $source, string $destination): void
96  {
97  $this->directoryAccess->copyDir($source, $destination);
98  }
99 
100 
104  public function deleteDir(string $path): void
105  {
106  $this->directoryAccess->deleteDir($path);
107  }
108 
109 
113  public function read(string $path): string
114  {
115  return $this->fileAccess->read($path);
116  }
117 
118 
122  public function has(string $path): bool
123  {
124  return $this->fileAccess->has($path);
125  }
126 
127 
131  public function getMimeType(string $path): string
132  {
133  return $this->fileAccess->getMimeType($path);
134  }
135 
136 
140  public function getTimestamp(string $path): \DateTimeImmutable
141  {
142  return $this->fileAccess->getTimestamp($path);
143  }
144 
145 
149  public function getSize(string $path, int $fileSizeUnit): DataSize
150  {
151  return $this->fileAccess->getSize($path, $fileSizeUnit);
152  }
153 
154 
158  public function setVisibility(string $path, string $visibility): bool
159  {
160  return $this->fileAccess->setVisibility($path, $visibility);
161  }
162 
163 
167  public function getVisibility(string $path): string
168  {
169  return $this->fileAccess->getVisibility($path);
170  }
171 
172 
176  public function readStream(string $path): FileStream
177  {
178  return $this->fileStreamAccess->readStream($path);
179  }
180 
181 
185  public function writeStream(string $path, FileStream $stream): void
186  {
187  $this->fileStreamAccess->writeStream($path, $stream);
188  }
189 
190 
194  public function putStream(string $path, FileStream $stream): void
195  {
196  $this->fileStreamAccess->putStream($path, $stream);
197  }
198 
199 
203  public function updateStream(string $path, FileStream $stream): void
204  {
205  $this->fileStreamAccess->updateStream($path, $stream);
206  }
207 
208 
212  public function write(string $path, string $content): void
213  {
214  $this->fileAccess->write($path, $content);
215  }
216 
217 
221  public function update(string $path, string $new_content): void
222  {
223  $this->fileAccess->update($path, $new_content);
224  }
225 
226 
230  public function put(string $path, string $content): void
231  {
232  $this->fileAccess->put($path, $content);
233  }
234 
235 
239  public function delete(string $path): void
240  {
241  $this->fileAccess->delete($path);
242  }
243 
244 
248  public function readAndDelete(string $path): string
249  {
250  return $this->fileAccess->readAndDelete($path);
251  }
252 
253 
257  public function rename(string $path, string $new_path): void
258  {
259  $this->fileAccess->rename($path, $new_path);
260  }
261 
262 
266  public function copy(string $path, string $copy_path): void
267  {
268  $this->fileAccess->copy($path, $copy_path);
269  }
270 
274  public function finder(): Finder
275  {
276  return new Finder($this);
277  }
278 }
write(string $path, string $content)
setVisibility(string $path, string $visibility)
rename(string $path, string $new_path)
This class provides the data size with additional information to remove the work to calculate the siz...
Definition: DataSize.php:30
$path
Definition: ltiservices.php:32
copyDir(string $source, string $destination)
createDir(string $path, string $visibility=Visibility::PUBLIC_ACCESS)
getSize(string $path, int $fileSizeUnit)
listContents(string $path='', bool $recursive=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
put(string $path, string $content)
getSize()
The calculated data size.
Definition: DataSize.php:119
copy(string $path, string $copy_path)
update(string $path, string $new_content)
__construct(FileStreamAccess $fileStreamAccess, FileAccess $fileAccess, DirectoryAccess $directoryAccess)
FilesystemFacade constructor.
const PUBLIC_ACCESS
Public file visibility.
Definition: Visibility.php:37
writeStream(string $path, FileStream $stream)
$source
Definition: metadata.php:93
Interface FileStream.
Definition: FileStream.php:33
putStream(string $path, FileStream $stream)
Class FlySystemFileAccessTest disabled disabled disabled.
updateStream(string $path, FileStream $stream)