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; |
13
|
|
|
|
14
|
|
|
use Puli\Repository\Api\EditableRepository; |
15
|
|
|
use Puli\Repository\Api\NoVersionFoundException; |
16
|
|
|
use Puli\Repository\Api\ResourceNotFoundException; |
17
|
|
|
use Puli\Repository\Resource\Collection\ArrayResourceCollection; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* A repository that does nothing. |
21
|
|
|
* |
22
|
|
|
* This repository can be used if you need to inject a repository instance in |
23
|
|
|
* some code, but you don't want that repository to do anything (for example |
24
|
|
|
* in tests). |
25
|
|
|
* |
26
|
|
|
* @since 1.0 |
27
|
|
|
* |
28
|
|
|
* @author Bernhard Schussek <[email protected]> |
29
|
|
|
*/ |
30
|
|
|
class NullRepository implements EditableRepository |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* {@inheritdoc} |
34
|
|
|
*/ |
35
|
5 |
|
public function add($path, $resource) |
36
|
|
|
{ |
37
|
5 |
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
*/ |
42
|
1 |
|
public function remove($query, $language = 'glob') |
43
|
|
|
{ |
44
|
1 |
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
*/ |
49
|
|
|
public function clear() |
50
|
|
|
{ |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* {@inheritdoc} |
55
|
|
|
*/ |
56
|
1 |
|
public function get($path) |
57
|
|
|
{ |
58
|
1 |
|
throw ResourceNotFoundException::forPath($path); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* {@inheritdoc} |
63
|
|
|
*/ |
64
|
1 |
|
public function getVersions($path) |
65
|
|
|
{ |
66
|
1 |
|
throw NoVersionFoundException::forPath($path); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* {@inheritdoc} |
71
|
|
|
*/ |
72
|
1 |
|
public function find($query, $language = 'glob') |
73
|
|
|
{ |
74
|
1 |
|
return new ArrayResourceCollection(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* {@inheritdoc} |
79
|
|
|
*/ |
80
|
2 |
|
public function contains($query, $language = 'glob') |
81
|
|
|
{ |
82
|
2 |
|
return false; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* {@inheritdoc} |
87
|
|
|
*/ |
88
|
1 |
|
public function hasChildren($path) |
89
|
|
|
{ |
90
|
1 |
|
return false; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* {@inheritdoc} |
95
|
|
|
*/ |
96
|
1 |
|
public function listChildren($path) |
97
|
|
|
{ |
98
|
1 |
|
return new ArrayResourceCollection(); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|