blob: f416b009d8340f61b887f3ba91eb17c41aff4065 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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);
}
|