1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14
|
|
|
* |
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
16
|
|
|
* and is licensed under the MIT license. For more information, see |
17
|
|
|
* <http://www.doctrine-project.org>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace Doctrine\ODM\MongoDB; |
21
|
|
|
|
22
|
|
|
use Doctrine\Common\Annotations\AnnotationReader; |
23
|
|
|
use Doctrine\Common\Cache\Cache; |
24
|
|
|
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver; |
25
|
|
|
use Doctrine\Common\Persistence\ObjectRepository; |
26
|
|
|
use Doctrine\ODM\MongoDB\DocumentRepository; |
27
|
|
|
use Doctrine\ODM\MongoDB\Mapping\ClassMetadataFactory; |
28
|
|
|
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver; |
29
|
|
|
use Doctrine\ODM\MongoDB\PersistentCollection\DefaultPersistentCollectionFactory; |
30
|
|
|
use Doctrine\ODM\MongoDB\PersistentCollection\DefaultPersistentCollectionGenerator; |
31
|
|
|
use Doctrine\ODM\MongoDB\PersistentCollection\PersistentCollectionFactory; |
32
|
|
|
use Doctrine\ODM\MongoDB\PersistentCollection\PersistentCollectionGenerator; |
33
|
|
|
use Doctrine\ODM\MongoDB\Repository\DefaultRepositoryFactory; |
34
|
|
|
use Doctrine\ODM\MongoDB\Repository\RepositoryFactory; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Configuration class for the DocumentManager. When setting up your DocumentManager |
38
|
|
|
* you can optionally specify an instance of this class as the second argument. |
39
|
|
|
* If you do not pass a configuration object, a blank one will be created for you. |
40
|
|
|
* |
41
|
|
|
* <?php |
42
|
|
|
* |
43
|
|
|
* $config = new Configuration(); |
44
|
|
|
* $dm = DocumentManager::create(new Connection(), $config); |
45
|
|
|
* |
46
|
|
|
* @since 1.0 |
47
|
|
|
* @author Jonathan H. Wage <[email protected]> |
48
|
|
|
* @author Roman Borschel <[email protected]> |
49
|
|
|
*/ |
50
|
|
|
class Configuration extends \Doctrine\MongoDB\Configuration |
51
|
|
|
{ |
52
|
|
|
/** |
53
|
|
|
* Never autogenerate a proxy/hydrator/persistent collection and rely that |
54
|
|
|
* it was generated by some process before deployment. Copied from |
55
|
|
|
* \Doctrine\Common\Proxy\AbstractProxyFactory. |
56
|
|
|
* |
57
|
|
|
* @var integer |
58
|
|
|
*/ |
59
|
|
|
const AUTOGENERATE_NEVER = 0; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Always generates a new proxy/hydrator/persistent collection in every request. |
63
|
|
|
* |
64
|
|
|
* This is only sane during development. |
65
|
|
|
* Copied from \Doctrine\Common\Proxy\AbstractProxyFactory. |
66
|
|
|
* |
67
|
|
|
* @var integer |
68
|
|
|
*/ |
69
|
|
|
const AUTOGENERATE_ALWAYS = 1; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Autogenerate the proxy/hydrator/persistent collection class when the file does not exist. |
73
|
|
|
* |
74
|
|
|
* This strategy causes a file exists call whenever any proxy/hydrator is used the |
75
|
|
|
* first time in a request. Copied from \Doctrine\Common\Proxy\AbstractProxyFactory. |
76
|
|
|
* |
77
|
|
|
* @var integer |
78
|
|
|
*/ |
79
|
|
|
const AUTOGENERATE_FILE_NOT_EXISTS = 2; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Generate the proxy/hydrator/persistent collection classes using eval(). |
83
|
|
|
* |
84
|
|
|
* This strategy is only sane for development. |
85
|
|
|
* Copied from \Doctrine\Common\Proxy\AbstractProxyFactory. |
86
|
|
|
* |
87
|
|
|
* @var integer |
88
|
|
|
*/ |
89
|
|
|
const AUTOGENERATE_EVAL = 3; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Adds a namespace under a certain alias. |
93
|
|
|
* |
94
|
|
|
* @param string $alias |
95
|
|
|
* @param string $namespace |
96
|
|
|
*/ |
97
|
|
|
public function addDocumentNamespace($alias, $namespace) |
98
|
|
|
{ |
99
|
|
|
$this->attributes['documentNamespaces'][$alias] = $namespace; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Resolves a registered namespace alias to the full namespace. |
104
|
|
|
* |
105
|
|
|
* @param string $documentNamespaceAlias |
106
|
|
|
* @return string |
107
|
|
|
* @throws MongoDBException |
108
|
|
|
*/ |
109
|
|
|
public function getDocumentNamespace($documentNamespaceAlias) |
110
|
|
|
{ |
111
|
|
|
if ( ! isset($this->attributes['documentNamespaces'][$documentNamespaceAlias])) { |
112
|
|
|
throw MongoDBException::unknownDocumentNamespace($documentNamespaceAlias); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
return trim($this->attributes['documentNamespaces'][$documentNamespaceAlias], '\\'); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Retrieves the list of registered document namespace aliases. |
120
|
|
|
* |
121
|
|
|
* @return array |
122
|
|
|
*/ |
123
|
|
|
public function getDocumentNamespaces() |
124
|
|
|
{ |
125
|
|
|
return $this->attributes['documentNamespaces']; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Set the document alias map |
130
|
|
|
* |
131
|
|
|
* @param array $documentNamespaces |
132
|
|
|
* @return void |
133
|
|
|
*/ |
134
|
|
|
public function setDocumentNamespaces(array $documentNamespaces) |
135
|
|
|
{ |
136
|
|
|
$this->attributes['documentNamespaces'] = $documentNamespaces; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Sets the cache driver implementation that is used for metadata caching. |
141
|
|
|
* |
142
|
|
|
* @param MappingDriver $driverImpl |
143
|
|
|
* @todo Force parameter to be a Closure to ensure lazy evaluation |
144
|
|
|
* (as soon as a metadata cache is in effect, the driver never needs to initialize). |
145
|
|
|
*/ |
146
|
949 |
|
public function setMetadataDriverImpl(MappingDriver $driverImpl) |
147
|
|
|
{ |
148
|
949 |
|
$this->attributes['metadataDriverImpl'] = $driverImpl; |
149
|
949 |
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Add a new default annotation driver with a correctly configured annotation reader. |
153
|
|
|
* |
154
|
|
|
* @param array $paths |
155
|
|
|
* @return Mapping\Driver\AnnotationDriver |
156
|
|
|
*/ |
157
|
|
|
public function newDefaultAnnotationDriver($paths = array()) |
158
|
|
|
{ |
159
|
|
|
$reader = new AnnotationReader(); |
160
|
|
|
|
161
|
|
|
return new AnnotationDriver($reader, (array)$paths); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Gets the cache driver implementation that is used for the mapping metadata. |
166
|
|
|
* |
167
|
|
|
* @return MappingDriver |
168
|
|
|
*/ |
169
|
761 |
|
public function getMetadataDriverImpl() |
170
|
|
|
{ |
171
|
761 |
|
return isset($this->attributes['metadataDriverImpl']) ? |
172
|
761 |
|
$this->attributes['metadataDriverImpl'] : null; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* Gets the cache driver implementation that is used for metadata caching. |
177
|
|
|
* |
178
|
|
|
* @return \Doctrine\Common\Cache\Cache |
179
|
|
|
*/ |
180
|
933 |
|
public function getMetadataCacheImpl() |
181
|
|
|
{ |
182
|
933 |
|
return isset($this->attributes['metadataCacheImpl']) ? |
183
|
933 |
|
$this->attributes['metadataCacheImpl'] : null; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Sets the cache driver implementation that is used for metadata caching. |
188
|
|
|
* |
189
|
|
|
* @param \Doctrine\Common\Cache\Cache $cacheImpl |
190
|
|
|
*/ |
191
|
|
|
public function setMetadataCacheImpl(Cache $cacheImpl) |
192
|
|
|
{ |
193
|
|
|
$this->attributes['metadataCacheImpl'] = $cacheImpl; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* Sets the directory where Doctrine generates any necessary proxy class files. |
198
|
|
|
* |
199
|
|
|
* @param string $dir |
200
|
|
|
*/ |
201
|
933 |
|
public function setProxyDir($dir) |
202
|
|
|
{ |
203
|
933 |
|
$this->attributes['proxyDir'] = $dir; |
204
|
933 |
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* Gets the directory where Doctrine generates any necessary proxy class files. |
208
|
|
|
* |
209
|
|
|
* @return string |
210
|
|
|
*/ |
211
|
933 |
|
public function getProxyDir() |
212
|
|
|
{ |
213
|
933 |
|
return isset($this->attributes['proxyDir']) ? |
214
|
933 |
|
$this->attributes['proxyDir'] : null; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* Gets a boolean flag that indicates whether proxy classes should always be regenerated |
219
|
|
|
* during each script execution. |
220
|
|
|
* |
221
|
|
|
* @return boolean|integer |
222
|
|
|
*/ |
223
|
933 |
|
public function getAutoGenerateProxyClasses() |
224
|
|
|
{ |
225
|
933 |
|
return isset($this->attributes['autoGenerateProxyClasses']) ? |
226
|
933 |
|
$this->attributes['autoGenerateProxyClasses'] : true; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* Sets a boolean flag that indicates whether proxy classes should always be regenerated |
231
|
|
|
* during each script execution. |
232
|
|
|
* |
233
|
|
|
* @param boolean|int $bool Possible values are constants of Doctrine\Common\Proxy\AbstractProxyFactory |
234
|
|
|
*/ |
235
|
|
|
public function setAutoGenerateProxyClasses($bool) |
236
|
|
|
{ |
237
|
|
|
$this->attributes['autoGenerateProxyClasses'] = $bool; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* Gets the namespace where proxy classes reside. |
242
|
|
|
* |
243
|
|
|
* @return string |
244
|
|
|
*/ |
245
|
933 |
|
public function getProxyNamespace() |
246
|
|
|
{ |
247
|
933 |
|
return isset($this->attributes['proxyNamespace']) ? |
248
|
933 |
|
$this->attributes['proxyNamespace'] : null; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Sets the namespace where proxy classes reside. |
253
|
|
|
* |
254
|
|
|
* @param string $ns |
255
|
|
|
*/ |
256
|
933 |
|
public function setProxyNamespace($ns) |
257
|
|
|
{ |
258
|
933 |
|
$this->attributes['proxyNamespace'] = $ns; |
259
|
933 |
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* Sets the directory where Doctrine generates hydrator class files. |
263
|
|
|
* |
264
|
|
|
* @param string $dir |
265
|
|
|
*/ |
266
|
933 |
|
public function setHydratorDir($dir) |
267
|
|
|
{ |
268
|
933 |
|
$this->attributes['hydratorDir'] = $dir; |
269
|
933 |
|
} |
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* Gets the directory where Doctrine generates hydrator class files. |
273
|
|
|
* |
274
|
|
|
* @return string |
275
|
|
|
*/ |
276
|
933 |
|
public function getHydratorDir() |
277
|
|
|
{ |
278
|
933 |
|
return isset($this->attributes['hydratorDir']) ? |
279
|
933 |
|
$this->attributes['hydratorDir'] : null; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* Gets a boolean flag that indicates whether hydrator classes should always be regenerated |
284
|
|
|
* during each script execution. |
285
|
|
|
* |
286
|
|
|
* @return boolean|integer Possible values are defined constants |
287
|
|
|
*/ |
288
|
933 |
|
public function getAutoGenerateHydratorClasses() |
289
|
|
|
{ |
290
|
933 |
|
return isset($this->attributes['autoGenerateHydratorClasses']) ? |
291
|
933 |
|
$this->attributes['autoGenerateHydratorClasses'] : true; |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* Sets a boolean flag that indicates whether hydrator classes should always be regenerated |
296
|
|
|
* during each script execution. |
297
|
|
|
* |
298
|
|
|
* @param boolean|integer $bool |
299
|
|
|
*/ |
300
|
|
|
public function setAutoGenerateHydratorClasses($bool) |
301
|
|
|
{ |
302
|
|
|
$this->attributes['autoGenerateHydratorClasses'] = $bool; |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* Gets the namespace where hydrator classes reside. |
307
|
|
|
* |
308
|
|
|
* @return string |
309
|
|
|
*/ |
310
|
933 |
|
public function getHydratorNamespace() |
311
|
|
|
{ |
312
|
933 |
|
return isset($this->attributes['hydratorNamespace']) ? |
313
|
933 |
|
$this->attributes['hydratorNamespace'] : null; |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
/** |
317
|
|
|
* Sets the namespace where hydrator classes reside. |
318
|
|
|
* |
319
|
|
|
* @param string $ns |
320
|
|
|
*/ |
321
|
933 |
|
public function setHydratorNamespace($ns) |
322
|
|
|
{ |
323
|
933 |
|
$this->attributes['hydratorNamespace'] = $ns; |
324
|
933 |
|
} |
325
|
|
|
|
326
|
|
|
/** |
327
|
|
|
* Sets the directory where Doctrine generates persistent collection class files. |
328
|
|
|
* |
329
|
|
|
* @param string $dir |
330
|
|
|
*/ |
331
|
933 |
|
public function setPersistentCollectionDir($dir) |
332
|
|
|
{ |
333
|
933 |
|
$this->attributes['persistentCollectionDir'] = $dir; |
334
|
933 |
|
} |
335
|
|
|
|
336
|
|
|
/** |
337
|
|
|
* Gets the directory where Doctrine generates persistent collection class files. |
338
|
|
|
* |
339
|
|
|
* @return string |
340
|
|
|
*/ |
341
|
|
|
public function getPersistentCollectionDir() |
342
|
|
|
{ |
343
|
|
|
return isset($this->attributes['persistentCollectionDir']) ? |
344
|
|
|
$this->attributes['persistentCollectionDir'] : null; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* Gets a integer flag that indicates how and when persistent collection |
349
|
|
|
* classes should be generated. |
350
|
|
|
* |
351
|
|
|
* @return integer Possible values are defined constants |
352
|
|
|
*/ |
353
|
4 |
|
public function getAutoGeneratePersistentCollectionClasses() |
354
|
|
|
{ |
355
|
4 |
|
return isset($this->attributes['autoGeneratePersistentCollectionClasses']) ? |
356
|
4 |
|
$this->attributes['autoGeneratePersistentCollectionClasses'] : self::AUTOGENERATE_ALWAYS; |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
/** |
360
|
|
|
* Sets a integer flag that indicates how and when persistent collection |
361
|
|
|
* classes should be generated. |
362
|
|
|
* |
363
|
|
|
* @param integer $mode Possible values are defined constants |
364
|
|
|
*/ |
365
|
|
|
public function setAutoGeneratePersistentCollectionClasses($mode) |
366
|
|
|
{ |
367
|
|
|
$this->attributes['autoGeneratePersistentCollectionClasses'] = $mode; |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
/** |
371
|
|
|
* Gets the namespace where persistent collection classes reside. |
372
|
|
|
* |
373
|
|
|
* @return string |
374
|
|
|
*/ |
375
|
|
|
public function getPersistentCollectionNamespace() |
376
|
|
|
{ |
377
|
|
|
return isset($this->attributes['persistentCollectionNamespace']) ? |
378
|
|
|
$this->attributes['persistentCollectionNamespace'] : null; |
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
/** |
382
|
|
|
* Sets the namespace where persistent collection classes reside. |
383
|
|
|
* |
384
|
|
|
* @param string $ns |
385
|
|
|
*/ |
386
|
933 |
|
public function setPersistentCollectionNamespace($ns) |
387
|
|
|
{ |
388
|
933 |
|
$this->attributes['persistentCollectionNamespace'] = $ns; |
389
|
933 |
|
} |
390
|
|
|
|
391
|
|
|
/** |
392
|
|
|
* Sets the default DB to use for all Documents that do not specify |
393
|
|
|
* a database. |
394
|
|
|
* |
395
|
|
|
* @param string $defaultDB |
396
|
|
|
*/ |
397
|
933 |
|
public function setDefaultDB($defaultDB) |
398
|
|
|
{ |
399
|
933 |
|
$this->attributes['defaultDB'] = $defaultDB; |
400
|
933 |
|
} |
401
|
|
|
|
402
|
|
|
/** |
403
|
|
|
* Gets the default DB to use for all Documents that do not specify a database. |
404
|
|
|
* |
405
|
|
|
* @return string $defaultDB |
406
|
|
|
*/ |
407
|
682 |
|
public function getDefaultDB() |
408
|
|
|
{ |
409
|
682 |
|
return isset($this->attributes['defaultDB']) ? |
410
|
682 |
|
$this->attributes['defaultDB'] : null; |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
/** |
414
|
|
|
* Set the class metadata factory class name. |
415
|
|
|
* |
416
|
|
|
* @param string $cmfName |
417
|
|
|
*/ |
418
|
|
|
public function setClassMetadataFactoryName($cmfName) |
419
|
|
|
{ |
420
|
|
|
$this->attributes['classMetadataFactoryName'] = $cmfName; |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
/** |
424
|
|
|
* Gets the class metadata factory class name. |
425
|
|
|
* |
426
|
|
|
* @return string |
427
|
|
|
*/ |
428
|
933 |
|
public function getClassMetadataFactoryName() |
429
|
|
|
{ |
430
|
933 |
|
if ( ! isset($this->attributes['classMetadataFactoryName'])) { |
431
|
933 |
|
$this->attributes['classMetadataFactoryName'] = ClassMetadataFactory::class; |
432
|
933 |
|
} |
433
|
933 |
|
return $this->attributes['classMetadataFactoryName']; |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
/** |
437
|
|
|
* Gets array of default commit options. |
438
|
|
|
* |
439
|
|
|
* @return array |
440
|
|
|
*/ |
441
|
560 |
|
public function getDefaultCommitOptions() |
442
|
|
|
{ |
443
|
560 |
|
if (isset($this->attributes['defaultCommitOptions'])) { |
444
|
|
|
return $this->attributes['defaultCommitOptions']; |
445
|
|
|
} |
446
|
|
|
|
447
|
560 |
|
return array('w' => 1); |
448
|
|
|
} |
449
|
|
|
|
450
|
|
|
/** |
451
|
|
|
* Sets array of default commit options. |
452
|
|
|
* |
453
|
|
|
* @param boolean $defaultCommitOptions |
454
|
|
|
*/ |
455
|
|
|
public function setDefaultCommitOptions($defaultCommitOptions) |
456
|
|
|
{ |
457
|
|
|
$this->attributes['defaultCommitOptions'] = $defaultCommitOptions; |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
/** |
461
|
|
|
* Add a filter to the list of possible filters. |
462
|
|
|
* |
463
|
|
|
* @param string $name The name of the filter. |
464
|
|
|
* @param string $className The class name of the filter. |
465
|
|
|
* @param array $parameters The parameters for the filter. |
466
|
|
|
*/ |
467
|
933 |
|
public function addFilter($name, $className, array $parameters = array()) |
468
|
|
|
{ |
469
|
933 |
|
$this->attributes['filters'][$name] = array( |
470
|
933 |
|
'class' => $className, |
471
|
|
|
'parameters' => $parameters |
472
|
933 |
|
); |
473
|
933 |
|
} |
474
|
|
|
|
475
|
|
|
/** |
476
|
|
|
* Gets the class name for a given filter name. |
477
|
|
|
* |
478
|
|
|
* @param string $name The name of the filter. |
479
|
|
|
* |
480
|
|
|
* @return string|null The filter class name, or null if it is undefined |
481
|
|
|
*/ |
482
|
22 |
|
public function getFilterClassName($name) |
483
|
|
|
{ |
484
|
22 |
|
return isset($this->attributes['filters'][$name]) |
485
|
22 |
|
? $this->attributes['filters'][$name]['class'] |
486
|
22 |
|
: null; |
487
|
|
|
} |
488
|
|
|
|
489
|
|
|
/** |
490
|
|
|
* Gets the parameters for a given filter name. |
491
|
|
|
* |
492
|
|
|
* @param string $name The name of the filter. |
493
|
|
|
* |
494
|
|
|
* @return array|null The filter parameters, or null if it is undefined |
495
|
|
|
*/ |
496
|
21 |
|
public function getFilterParameters($name) |
497
|
|
|
{ |
498
|
21 |
|
return isset($this->attributes['filters'][$name]) |
499
|
21 |
|
? $this->attributes['filters'][$name]['parameters'] |
500
|
21 |
|
: null; |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
/** |
504
|
|
|
* Sets default repository class. |
505
|
|
|
* |
506
|
|
|
* @param string $className |
507
|
|
|
* |
508
|
|
|
* @return void |
509
|
|
|
* |
510
|
|
|
* @throws MongoDBException If not is a ObjectRepository |
511
|
|
|
*/ |
512
|
|
|
public function setDefaultRepositoryClassName($className) |
513
|
|
|
{ |
514
|
|
|
$reflectionClass = new \ReflectionClass($className); |
515
|
|
|
|
516
|
|
|
if ( ! $reflectionClass->implementsInterface(ObjectRepository::class)) { |
517
|
|
|
throw MongoDBException::invalidDocumentRepository($className); |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
$this->attributes['defaultRepositoryClassName'] = $className; |
521
|
|
|
} |
522
|
|
|
|
523
|
|
|
/** |
524
|
|
|
* Get default repository class. |
525
|
|
|
* |
526
|
|
|
* @return string |
527
|
|
|
*/ |
528
|
325 |
|
public function getDefaultRepositoryClassName() |
529
|
|
|
{ |
530
|
325 |
|
return isset($this->attributes['defaultRepositoryClassName']) |
531
|
325 |
|
? $this->attributes['defaultRepositoryClassName'] |
532
|
325 |
|
: DocumentRepository::class; |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
/** |
536
|
|
|
* Set the document repository factory. |
537
|
|
|
* |
538
|
|
|
* @param RepositoryFactory $repositoryFactory |
539
|
|
|
*/ |
540
|
|
|
public function setRepositoryFactory(RepositoryFactory $repositoryFactory) |
541
|
|
|
{ |
542
|
|
|
$this->attributes['repositoryFactory'] = $repositoryFactory; |
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
/** |
546
|
|
|
* Get the document repository factory. |
547
|
|
|
* |
548
|
|
|
* @return RepositoryFactory |
549
|
|
|
*/ |
550
|
933 |
|
public function getRepositoryFactory() |
551
|
|
|
{ |
552
|
933 |
|
return isset($this->attributes['repositoryFactory']) |
553
|
933 |
|
? $this->attributes['repositoryFactory'] |
554
|
933 |
|
: new DefaultRepositoryFactory(); |
555
|
|
|
} |
556
|
|
|
|
557
|
|
|
/** |
558
|
|
|
* Set the persistent collection factory. |
559
|
|
|
* |
560
|
|
|
* @param PersistentCollectionFactory $persistentCollectionFactory |
561
|
|
|
*/ |
562
|
|
|
public function setPersistentCollectionFactory(PersistentCollectionFactory $persistentCollectionFactory) |
563
|
|
|
{ |
564
|
|
|
$this->attributes['persistentCollectionFactory'] = $persistentCollectionFactory; |
565
|
|
|
} |
566
|
|
|
|
567
|
|
|
/** |
568
|
|
|
* Get the persistent collection factory. |
569
|
|
|
* |
570
|
|
|
* @return DefaultPersistentCollectionFactory |
571
|
|
|
*/ |
572
|
385 |
|
public function getPersistentCollectionFactory() |
573
|
|
|
{ |
574
|
385 |
|
if ( ! isset($this->attributes['persistentCollectionFactory'])) { |
575
|
385 |
|
$this->attributes['persistentCollectionFactory'] = new DefaultPersistentCollectionFactory(); |
576
|
385 |
|
} |
577
|
385 |
|
return $this->attributes['persistentCollectionFactory']; |
578
|
|
|
} |
579
|
|
|
|
580
|
|
|
/** |
581
|
|
|
* Set the persistent collection generator. |
582
|
|
|
* |
583
|
|
|
* @param PersistentCollectionGenerator $persistentCollectionGenerator |
584
|
|
|
*/ |
585
|
|
|
public function setPersistentCollectionGenerator(PersistentCollectionGenerator $persistentCollectionGenerator) |
586
|
|
|
{ |
587
|
|
|
$this->attributes['persistentCollectionGenerator'] = $persistentCollectionGenerator; |
588
|
|
|
} |
589
|
|
|
|
590
|
|
|
/** |
591
|
|
|
* Get the persistent collection generator. |
592
|
|
|
* |
593
|
|
|
* @return DefaultPersistentCollectionGenerator |
594
|
|
|
*/ |
595
|
5 |
|
public function getPersistentCollectionGenerator() |
596
|
|
|
{ |
597
|
5 |
|
if ( ! isset($this->attributes['persistentCollectionGenerator'])) { |
598
|
5 |
|
$this->attributes['persistentCollectionGenerator'] = new DefaultPersistentCollectionGenerator( |
599
|
5 |
|
$this->attributes['persistentCollectionDir'], |
600
|
5 |
|
$this->attributes['persistentCollectionNamespace'] |
601
|
5 |
|
); |
602
|
5 |
|
} |
603
|
5 |
|
return $this->attributes['persistentCollectionGenerator']; |
604
|
|
|
} |
605
|
|
|
} |
606
|
|
|
|