diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:46:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:46:43 +0000 |
commit | 3e02d5aff85babc3ffbfcf52313f2108e313aa23 (patch) | |
tree | b01f3923360c20a6a504aff42d45670c58af3ec5 /library/Icinga/File/Storage/StorageInterface.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-3e02d5aff85babc3ffbfcf52313f2108e313aa23.tar.xz icingaweb2-3e02d5aff85babc3ffbfcf52313f2108e313aa23.zip |
Adding upstream version 2.12.1.upstream/2.12.1upstream
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); +} |