diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:39:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:39:39 +0000 |
commit | 8ca6cc32b2c789a3149861159ad258f2cb9491e3 (patch) | |
tree | 2492de6f1528dd44eaa169a5c1555026d9cb75ec /library/Icinga/File/Storage/StorageInterface.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-upstream.tar.xz icingaweb2-upstream.zip |
Adding upstream version 2.11.4.upstream/2.11.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Icinga/File/Storage/StorageInterface.php')
-rw-r--r-- | library/Icinga/File/Storage/StorageInterface.php | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/library/Icinga/File/Storage/StorageInterface.php b/library/Icinga/File/Storage/StorageInterface.php new file mode 100644 index 0000000..f416b00 --- /dev/null +++ b/library/Icinga/File/Storage/StorageInterface.php @@ -0,0 +1,94 @@ +<?php +/* Icinga Web 2 | (c) 2017 Icinga Development Team | GPLv2+ */ + +namespace Icinga\File\Storage; + +use Icinga\Exception\AlreadyExistsException; +use Icinga\Exception\NotFoundError; +use Icinga\Exception\NotReadableError; +use Icinga\Exception\NotWritableError; +use IteratorAggregate; +use Traversable; + +interface StorageInterface extends IteratorAggregate +{ + /** + * Iterate over all existing files' paths + * + * @return Traversable + * + * @throws NotReadableError If the file list can't be read + */ + public function getIterator(): Traversable; + + /** + * Return whether the given file exists + * + * @param string $path + * + * @return bool + */ + public function has($path); + + /** + * Create the given file with the given content + * + * @param string $path + * @param mixed $content + * + * @return $this + * + * @throws AlreadyExistsException If the file already exists + * @throws NotWritableError If the file can't be written to + */ + public function create($path, $content); + + /** + * Load the content of the given file + * + * @param string $path + * + * @return mixed + * + * @throws NotFoundError If the file can't be found + * @throws NotReadableError If the file can't be read + */ + public function read($path); + + /** + * Overwrite the given file with the given content + * + * @param string $path + * @param mixed $content + * + * @return $this + * + * @throws NotFoundError If the file can't be found + * @throws NotWritableError If the file can't be written to + */ + public function update($path, $content); + + /** + * Delete the given file + * + * @param string $path + * + * @return $this + * + * @throws NotFoundError If the file can't be found + * @throws NotWritableError If the file can't be deleted + */ + public function delete($path); + + /** + * Get the absolute path to the given file + * + * @param string $path + * @param bool $assertExistence Whether to require that the given file exists + * + * @return string + * + * @throws NotFoundError If the file has to exist, but can't be found + */ + public function resolvePath($path, $assertExistence = false); +} |