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