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