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