1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the puli/repository package. |
5
|
|
|
* |
6
|
|
|
* (c) Bernhard Schussek <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Puli\Repository\Api\ChangeStream; |
13
|
|
|
|
14
|
|
|
use Puli\Repository\Api\NoVersionFoundException; |
15
|
|
|
use Puli\Repository\Api\Resource\PuliResource; |
16
|
|
|
use Puli\Repository\Api\ResourceRepository; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Tracks different versions of a resource. |
20
|
|
|
* |
21
|
|
|
* @since 1.0 |
22
|
|
|
* |
23
|
|
|
* @author Titouan Galopin <[email protected]> |
24
|
|
|
* @author Bernhard Schussek <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
interface ChangeStream |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Stores a new version of a resource. |
30
|
|
|
* |
31
|
|
|
* @param PuliResource $resource The resource to store. |
32
|
|
|
*/ |
33
|
|
|
public function append(PuliResource $resource); |
|
|
|
|
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Removes all versions stored for a path. |
37
|
|
|
* |
38
|
|
|
* @param string $path The Puli path. |
39
|
|
|
*/ |
40
|
|
|
public function purge($path); |
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Returns whether the stream contains any version for a path. |
44
|
|
|
* |
45
|
|
|
* @param string $path The Puli path. |
46
|
|
|
* |
47
|
|
|
* @return bool Returns `true` if a version can be found and `false` otherwise. |
48
|
|
|
*/ |
49
|
|
|
public function contains($path); |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Removes all contents of the stream. |
53
|
|
|
*/ |
54
|
|
|
public function clear(); |
|
|
|
|
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Returns all versions of a resource. |
58
|
|
|
* |
59
|
|
|
* @param string $path The Puli path to look for. |
60
|
|
|
* @param ResourceRepository $repository The repository to attach the |
|
|
|
|
61
|
|
|
* resources to. |
62
|
|
|
* |
63
|
|
|
* @return VersionList The versions of the resource. |
64
|
|
|
* |
65
|
|
|
* @throws NoVersionFoundException If no version is found for the path. |
66
|
|
|
*/ |
67
|
|
|
public function getVersions($path, ResourceRepository $repository = null); |
68
|
|
|
} |
69
|
|
|
|
For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a
@return
doc comment to communicate to implementors of these methods what they are expected to return.