ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
FilesystemFacade.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Filesystem;
22 
29 
39 final class FilesystemFacade implements Filesystem
40 {
50  public function __construct(
51  private FileStreamAccess $fileStreamAccess,
52  private FileAccess $fileAccess,
53  private DirectoryAccess $directoryAccess
54  ) {
55  }
56 
60  public function hasDir(string $path): bool
61  {
62  return $this->directoryAccess->hasDir($path);
63  }
64 
68  public function listContents(string $path = '', bool $recursive = false): array
69  {
70  return $this->directoryAccess->listContents($path, $recursive);
71  }
72 
76  public function createDir(string $path, string $visibility = Visibility::PUBLIC_ACCESS): void
77  {
78  $this->directoryAccess->createDir($path, $visibility);
79  }
80 
84  public function copyDir(string $source, string $destination): void
85  {
86  $this->directoryAccess->copyDir($source, $destination);
87  }
88 
92  public function deleteDir(string $path): void
93  {
94  $this->directoryAccess->deleteDir($path);
95  }
96 
100  public function read(string $path): string
101  {
102  return $this->fileAccess->read($path);
103  }
104 
108  public function has(string $path): bool
109  {
110  return $this->fileAccess->has($path);
111  }
112 
116  public function getMimeType(string $path): string
117  {
118  return $this->fileAccess->getMimeType($path);
119  }
120 
124  public function getTimestamp(string $path): \DateTimeImmutable
125  {
126  return $this->fileAccess->getTimestamp($path);
127  }
128 
132  public function getSize(string $path, int $unit): DataSize
133  {
134  return $this->fileAccess->getSize($path, $unit);
135  }
136 
140  public function setVisibility(string $path, string $visibility): bool
141  {
142  return $this->fileAccess->setVisibility($path, $visibility);
143  }
144 
148  public function getVisibility(string $path): string
149  {
150  return $this->fileAccess->getVisibility($path);
151  }
152 
156  public function readStream(string $path): FileStream
157  {
158  return $this->fileStreamAccess->readStream($path);
159  }
160 
164  public function writeStream(string $path, FileStream $stream): void
165  {
166  $this->fileStreamAccess->writeStream($path, $stream);
167  }
168 
172  public function putStream(string $path, FileStream $stream): void
173  {
174  $this->fileStreamAccess->putStream($path, $stream);
175  }
176 
180  public function updateStream(string $path, FileStream $stream): void
181  {
182  $this->fileStreamAccess->updateStream($path, $stream);
183  }
184 
188  public function write(string $path, string $content): void
189  {
190  $this->fileAccess->write($path, $content);
191  }
192 
196  public function update(string $path, string $new_content): void
197  {
198  $this->fileAccess->update($path, $new_content);
199  }
200 
204  public function put(string $path, string $content): void
205  {
206  $this->fileAccess->put($path, $content);
207  }
208 
212  public function delete(string $path): void
213  {
214  $this->fileAccess->delete($path);
215  }
216 
220  public function readAndDelete(string $path): string
221  {
222  return $this->fileAccess->readAndDelete($path);
223  }
224 
228  public function rename(string $path, string $new_path): void
229  {
230  $this->fileAccess->rename($path, $new_path);
231  }
232 
236  public function copy(string $path, string $copy_path): void
237  {
238  $this->fileAccess->copy($path, $copy_path);
239  }
240 
244  public function finder(): Finder
245  {
246  return new Finder($this);
247  }
248 }
write(string $path, string $content)
setVisibility(string $path, string $visibility)
rename(string $path, string $new_path)
__construct(private FileStreamAccess $fileStreamAccess, private FileAccess $fileAccess, private DirectoryAccess $directoryAccess)
FilesystemFacade constructor.
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:29
copyDir(string $source, string $destination)
createDir(string $path, string $visibility=Visibility::PUBLIC_ACCESS)
listContents(string $path='', bool $recursive=false)
getSize(string $path, int $unit)
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:112
copy(string $path, string $copy_path)
update(string $path, string $new_content)
const PUBLIC_ACCESS
Public file visibility.
Definition: Visibility.php:34
writeStream(string $path, FileStream $stream)
putStream(string $path, FileStream $stream)
updateStream(string $path, FileStream $stream)
The filesystem facade is used internally to satisfy the Filesystem interface because the implementati...