1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Cubiche package. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) Cubiche |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
namespace Cubiche\Infrastructure\Collections\Doctrine\Common\Collections; |
12
|
|
|
|
13
|
|
|
use Cubiche\Core\Collections\CollectionInterface; |
14
|
|
|
use Doctrine\ODM\MongoDB\DocumentManager; |
15
|
|
|
use Doctrine\ODM\MongoDB\PersistentCollection; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Persistent Collection Adapter Class. |
19
|
|
|
* |
20
|
|
|
* @author Karel Osorio Ramírez <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
abstract class PersistentCollectionAdapter extends PersistentCollection implements CollectionInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var PersistentCollection |
26
|
|
|
*/ |
27
|
|
|
protected $collection; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param PersistentCollection $collection |
31
|
|
|
*/ |
32
|
|
|
public function __construct(PersistentCollection $collection) |
33
|
|
|
{ |
34
|
|
|
$this->collection = $collection; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
|
|
public function setDocumentManager(DocumentManager $dm) |
41
|
|
|
{ |
42
|
|
|
$this->collection->setDocumentManager($dm); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritdoc} |
47
|
|
|
*/ |
48
|
|
|
public function setMongoData(array $mongoData) |
49
|
|
|
{ |
50
|
|
|
$this->collection->setMongoData($mongoData); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* {@inheritdoc} |
55
|
|
|
*/ |
56
|
|
|
public function getMongoData() |
57
|
|
|
{ |
58
|
|
|
return $this->collection->getMongoData(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* {@inheritdoc} |
63
|
|
|
*/ |
64
|
|
|
public function setHints(array $hints) |
65
|
|
|
{ |
66
|
|
|
$this->collection->setHints($hints); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* {@inheritdoc} |
71
|
|
|
*/ |
72
|
|
|
public function getHints() |
73
|
|
|
{ |
74
|
|
|
return $this->collection->getHints(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* {@inheritdoc} |
79
|
|
|
*/ |
80
|
|
|
public function initialize() |
81
|
|
|
{ |
82
|
|
|
$this->collection->initialize(); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* {@inheritdoc} |
87
|
|
|
*/ |
88
|
|
|
public function isDirty() |
89
|
|
|
{ |
90
|
|
|
return $this->collection->isDirty(); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* {@inheritdoc} |
95
|
|
|
*/ |
96
|
|
|
public function setDirty($dirty) |
97
|
|
|
{ |
98
|
|
|
$this->collection->setDirty($dirty); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* {@inheritdoc} |
103
|
|
|
*/ |
104
|
|
|
public function setOwner($document, array $mapping) |
105
|
|
|
{ |
106
|
|
|
$this->collection->setOwner($document, $mapping); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* {@inheritdoc} |
111
|
|
|
*/ |
112
|
|
|
public function takeSnapshot() |
113
|
|
|
{ |
114
|
|
|
$this->collection->takeSnapshot(); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* {@inheritdoc} |
119
|
|
|
*/ |
120
|
|
|
public function clearSnapshot() |
121
|
|
|
{ |
122
|
|
|
$this->collection->clearSnapshot(); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* {@inheritdoc} |
127
|
|
|
*/ |
128
|
|
|
public function getSnapshot() |
129
|
|
|
{ |
130
|
|
|
return $this->collection->getSnapshot(); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* {@inheritdoc} |
135
|
|
|
*/ |
136
|
|
|
public function getDeleteDiff() |
137
|
|
|
{ |
138
|
|
|
return $this->collection->getDeleteDiff(); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* {@inheritdoc} |
143
|
|
|
*/ |
144
|
|
|
public function getDeletedDocuments() |
145
|
|
|
{ |
146
|
|
|
return $this->collection->getDeletedDocuments(); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* {@inheritdoc} |
151
|
|
|
*/ |
152
|
|
|
public function getInsertDiff() |
153
|
|
|
{ |
154
|
|
|
return $this->collection->getInsertDiff(); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* {@inheritdoc} |
159
|
|
|
*/ |
160
|
|
|
public function getOwner() |
161
|
|
|
{ |
162
|
|
|
return $this->collection->getOwner(); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* {@inheritdoc} |
167
|
|
|
*/ |
168
|
|
|
public function getMapping() |
169
|
|
|
{ |
170
|
|
|
return $this->collection->getMapping(); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* {@inheritdoc} |
175
|
|
|
*/ |
176
|
|
|
public function getTypeClass() |
177
|
|
|
{ |
178
|
|
|
return $this->collection->getTypeClass(); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* {@inheritdoc} |
183
|
|
|
*/ |
184
|
|
|
public function setInitialized($bool) |
185
|
|
|
{ |
186
|
|
|
$this->collection->setInitialized($bool); |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* {@inheritdoc} |
191
|
|
|
*/ |
192
|
|
|
public function isInitialized() |
193
|
|
|
{ |
194
|
|
|
return $this->collection->isInitialized(); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* {@inheritdoc} |
199
|
|
|
*/ |
200
|
|
|
public function first() |
201
|
|
|
{ |
202
|
|
|
return $this->collection->first(); |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* {@inheritdoc} |
207
|
|
|
*/ |
208
|
|
|
public function last() |
209
|
|
|
{ |
210
|
|
|
return $this->collection->last(); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* {@inheritdoc} |
215
|
|
|
*/ |
216
|
|
|
public function remove($key) |
217
|
|
|
{ |
218
|
|
|
return $this->collection->remove($key); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* {@inheritdoc} |
223
|
|
|
*/ |
224
|
|
|
public function removeElement($element) |
225
|
|
|
{ |
226
|
|
|
return $this->collection->removeElement($element); |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* {@inheritdoc} |
231
|
|
|
*/ |
232
|
|
|
public function containsKey($key) |
233
|
|
|
{ |
234
|
|
|
return $this->collection->containsKey($key); |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* {@inheritdoc} |
239
|
|
|
*/ |
240
|
|
|
public function contains($element) |
241
|
|
|
{ |
242
|
|
|
return $this->collection->contains($element); |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* {@inheritdoc} |
247
|
|
|
*/ |
248
|
|
|
public function exists(\Closure $p) |
249
|
|
|
{ |
250
|
|
|
return $this->collection->exists($p); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* {@inheritdoc} |
255
|
|
|
*/ |
256
|
|
|
public function indexOf($element) |
257
|
|
|
{ |
258
|
|
|
return $this->collection->indexOf($element); |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* {@inheritdoc} |
263
|
|
|
*/ |
264
|
|
|
public function get($key) |
265
|
|
|
{ |
266
|
|
|
return $this->collection->get($key); |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* {@inheritdoc} |
271
|
|
|
*/ |
272
|
|
|
public function getKeys() |
273
|
|
|
{ |
274
|
|
|
return $this->collection->getKeys(); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* {@inheritdoc} |
279
|
|
|
*/ |
280
|
|
|
public function getValues() |
281
|
|
|
{ |
282
|
|
|
return $this->collection->getValues(); |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* {@inheritdoc} |
287
|
|
|
*/ |
288
|
|
|
public function count() |
289
|
|
|
{ |
290
|
|
|
return $this->collection->count(); |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
/** |
294
|
|
|
* {@inheritdoc} |
295
|
|
|
*/ |
296
|
|
|
public function set($key, $value) |
297
|
|
|
{ |
298
|
|
|
$this->set($key, $value); |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
/** |
302
|
|
|
* {@inheritdoc} |
303
|
|
|
*/ |
304
|
|
|
public function add($value) |
305
|
|
|
{ |
306
|
|
|
return $this->collection->add($value); |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* {@inheritdoc} |
311
|
|
|
*/ |
312
|
|
|
public function isEmpty() |
313
|
|
|
{ |
314
|
|
|
return $this->collection->isEmpty(); |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* {@inheritdoc} |
319
|
|
|
*/ |
320
|
|
|
public function getIterator() |
321
|
|
|
{ |
322
|
|
|
return $this->collection->getIterator(); |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* {@inheritdoc} |
327
|
|
|
*/ |
328
|
|
|
public function map(\Closure $func) |
329
|
|
|
{ |
330
|
|
|
return $this->collection->map($func); |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
/** |
334
|
|
|
* {@inheritdoc} |
335
|
|
|
*/ |
336
|
|
|
public function filter(\Closure $p) |
337
|
|
|
{ |
338
|
|
|
return $this->collection->filter($p); |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
/** |
342
|
|
|
* {@inheritdoc} |
343
|
|
|
*/ |
344
|
|
|
public function forAll(\Closure $p) |
345
|
|
|
{ |
346
|
|
|
return $this->collection->forAll($p); |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
/** |
350
|
|
|
* {@inheritdoc} |
351
|
|
|
*/ |
352
|
|
|
public function partition(\Closure $p) |
353
|
|
|
{ |
354
|
|
|
return $this->collection->partition($p); |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
/** |
358
|
|
|
* {@inheritdoc} |
359
|
|
|
*/ |
360
|
|
|
public function toArray() |
361
|
|
|
{ |
362
|
|
|
return $this->collection->toArray(); |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
/** |
366
|
|
|
* {@inheritdoc} |
367
|
|
|
*/ |
368
|
|
|
public function clear() |
369
|
|
|
{ |
370
|
|
|
$this->collection->clear(); |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
/** |
374
|
|
|
* {@inheritdoc} |
375
|
|
|
*/ |
376
|
|
|
public function slice($offset, $length = null) |
377
|
|
|
{ |
378
|
|
|
return $this->collection->slice($offset, $length); |
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
/** |
382
|
|
|
* {@inheritdoc} |
383
|
|
|
*/ |
384
|
|
|
public function __sleep() |
385
|
|
|
{ |
386
|
|
|
return $this->collection->__sleep(); |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* {@inheritdoc} |
391
|
|
|
*/ |
392
|
|
|
public function offsetExists($offset) |
393
|
|
|
{ |
394
|
|
|
return $this->collection->offsetExists($offset); |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* {@inheritdoc} |
399
|
|
|
*/ |
400
|
|
|
public function offsetGet($offset) |
401
|
|
|
{ |
402
|
|
|
return $this->collection->offsetGet($offset); |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* {@inheritdoc} |
407
|
|
|
*/ |
408
|
|
|
public function offsetSet($offset, $value) |
409
|
|
|
{ |
410
|
|
|
return $this->collection->offsetSet($offset, $value); |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
/** |
414
|
|
|
* {@inheritdoc} |
415
|
|
|
*/ |
416
|
|
|
public function offsetUnset($offset) |
417
|
|
|
{ |
418
|
|
|
return $this->collection->offsetUnset($offset); |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
/** |
422
|
|
|
* {@inheritdoc} |
423
|
|
|
*/ |
424
|
|
|
public function key() |
425
|
|
|
{ |
426
|
|
|
return $this->collection->key(); |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* {@inheritdoc} |
431
|
|
|
*/ |
432
|
|
|
public function current() |
433
|
|
|
{ |
434
|
|
|
return $this->collection->current(); |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
/** |
438
|
|
|
* {@inheritdoc} |
439
|
|
|
*/ |
440
|
|
|
public function next() |
441
|
|
|
{ |
442
|
|
|
return $this->collection->next(); |
443
|
|
|
} |
444
|
|
|
|
445
|
|
|
/** |
446
|
|
|
* {@inheritdoc} |
447
|
|
|
*/ |
448
|
|
|
public function unwrap() |
449
|
|
|
{ |
450
|
|
|
return $this->collection->unwrap(); |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
/** |
454
|
|
|
* {@inheritdoc} |
455
|
|
|
*/ |
456
|
|
|
public function __clone() |
457
|
|
|
{ |
458
|
|
|
clone $this->collection; |
459
|
|
|
} |
460
|
|
|
} |
461
|
|
|
|