1 | <?php |
||
12 | class FileCollection extends Collection |
||
13 | { |
||
14 | /** |
||
15 | * @var array Index of files by uid |
||
16 | */ |
||
17 | protected $index = []; |
||
18 | |||
19 | /** |
||
20 | * Adds file to the collection |
||
21 | * |
||
22 | * @param File $file |
||
23 | */ |
||
24 | 9 | public function addFile(File $file) |
|
28 | |||
29 | /** |
||
30 | * Filter the collection |
||
31 | * |
||
32 | * @param array $filters Array of Filter objects |
||
33 | * |
||
34 | * @throws FilterException |
||
35 | */ |
||
36 | 4 | public function filter(array $filters) |
|
56 | |||
57 | /** |
||
58 | * Add file and update index |
||
59 | * |
||
60 | * @param File $file |
||
61 | * @param string $key |
||
62 | */ |
||
63 | 9 | public function add($file, $key = null) |
|
69 | |||
70 | /** |
||
71 | * Del file and update index |
||
72 | * |
||
73 | * @param string $key File key |
||
74 | */ |
||
75 | 2 | public function del($key) |
|
84 | |||
85 | /** |
||
86 | * Search the file using index |
||
87 | * |
||
88 | * @param string $uid Unique id of file |
||
89 | * |
||
90 | * @return null|File |
||
91 | */ |
||
92 | 4 | public function getByUid($uid) |
|
107 | |||
108 | /** |
||
109 | * Add file to index for searching |
||
110 | * |
||
111 | * @param File $file |
||
112 | */ |
||
113 | 9 | protected function addToIndex(File $file) |
|
127 | |||
128 | /** |
||
129 | * Delete file from index |
||
130 | * |
||
131 | * @param File $file |
||
132 | * |
||
133 | * @return bool |
||
134 | */ |
||
135 | 2 | protected function deleteFromIndex(File $file) |
|
156 | } |
||
157 |