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 LGPL. For more information, see |
---|
17 | * <http://www.doctrine-project.org>. |
---|
18 | */ |
---|
19 | |
---|
20 | namespace Doctrine\ORM; |
---|
21 | |
---|
22 | use Doctrine\Common\Cache\Cache, |
---|
23 | Doctrine\Common\Cache\ArrayCache, |
---|
24 | Doctrine\Common\Annotations\AnnotationRegistry, |
---|
25 | Doctrine\Common\Annotations\AnnotationReader, |
---|
26 | Doctrine\ORM\Mapping\Driver\Driver, |
---|
27 | Doctrine\ORM\Mapping\Driver\AnnotationDriver; |
---|
28 | |
---|
29 | /** |
---|
30 | * Configuration container for all configuration options of Doctrine. |
---|
31 | * It combines all configuration options from DBAL & ORM. |
---|
32 | * |
---|
33 | * @since 2.0 |
---|
34 | * @internal When adding a new configuration option just write a getter/setter pair. |
---|
35 | * @author Benjamin Eberlei <kontakt@beberlei.de> |
---|
36 | * @author Guilherme Blanco <guilhermeblanco@hotmail.com> |
---|
37 | * @author Jonathan Wage <jonwage@gmail.com> |
---|
38 | * @author Roman Borschel <roman@code-factory.org> |
---|
39 | */ |
---|
40 | class Configuration extends \Doctrine\DBAL\Configuration |
---|
41 | { |
---|
42 | /** |
---|
43 | * Sets the directory where Doctrine generates any necessary proxy class files. |
---|
44 | * |
---|
45 | * @param string $dir |
---|
46 | */ |
---|
47 | public function setProxyDir($dir) |
---|
48 | { |
---|
49 | $this->_attributes['proxyDir'] = $dir; |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | * Gets the directory where Doctrine generates any necessary proxy class files. |
---|
54 | * |
---|
55 | * @return string |
---|
56 | */ |
---|
57 | public function getProxyDir() |
---|
58 | { |
---|
59 | return isset($this->_attributes['proxyDir']) ? |
---|
60 | $this->_attributes['proxyDir'] : null; |
---|
61 | } |
---|
62 | |
---|
63 | /** |
---|
64 | * Gets a boolean flag that indicates whether proxy classes should always be regenerated |
---|
65 | * during each script execution. |
---|
66 | * |
---|
67 | * @return boolean |
---|
68 | */ |
---|
69 | public function getAutoGenerateProxyClasses() |
---|
70 | { |
---|
71 | return isset($this->_attributes['autoGenerateProxyClasses']) ? |
---|
72 | $this->_attributes['autoGenerateProxyClasses'] : true; |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * Sets a boolean flag that indicates whether proxy classes should always be regenerated |
---|
77 | * during each script execution. |
---|
78 | * |
---|
79 | * @param boolean $bool |
---|
80 | */ |
---|
81 | public function setAutoGenerateProxyClasses($bool) |
---|
82 | { |
---|
83 | $this->_attributes['autoGenerateProxyClasses'] = $bool; |
---|
84 | } |
---|
85 | |
---|
86 | /** |
---|
87 | * Gets the namespace where proxy classes reside. |
---|
88 | * |
---|
89 | * @return string |
---|
90 | */ |
---|
91 | public function getProxyNamespace() |
---|
92 | { |
---|
93 | return isset($this->_attributes['proxyNamespace']) ? |
---|
94 | $this->_attributes['proxyNamespace'] : null; |
---|
95 | } |
---|
96 | |
---|
97 | /** |
---|
98 | * Sets the namespace where proxy classes reside. |
---|
99 | * |
---|
100 | * @param string $ns |
---|
101 | */ |
---|
102 | public function setProxyNamespace($ns) |
---|
103 | { |
---|
104 | $this->_attributes['proxyNamespace'] = $ns; |
---|
105 | } |
---|
106 | |
---|
107 | /** |
---|
108 | * Sets the cache driver implementation that is used for metadata caching. |
---|
109 | * |
---|
110 | * @param Driver $driverImpl |
---|
111 | * @todo Force parameter to be a Closure to ensure lazy evaluation |
---|
112 | * (as soon as a metadata cache is in effect, the driver never needs to initialize). |
---|
113 | */ |
---|
114 | public function setMetadataDriverImpl(Driver $driverImpl) |
---|
115 | { |
---|
116 | $this->_attributes['metadataDriverImpl'] = $driverImpl; |
---|
117 | } |
---|
118 | |
---|
119 | /** |
---|
120 | * Add a new default annotation driver with a correctly configured annotation reader. |
---|
121 | * |
---|
122 | * @param array $paths |
---|
123 | * @return Mapping\Driver\AnnotationDriver |
---|
124 | */ |
---|
125 | public function newDefaultAnnotationDriver($paths = array()) |
---|
126 | { |
---|
127 | if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) { |
---|
128 | // Register the ORM Annotations in the AnnotationRegistry |
---|
129 | AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php'); |
---|
130 | |
---|
131 | $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); |
---|
132 | $reader->addNamespace('Doctrine\ORM\Mapping'); |
---|
133 | $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache()); |
---|
134 | } else if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-DEV', '>=')) { |
---|
135 | // Register the ORM Annotations in the AnnotationRegistry |
---|
136 | AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php'); |
---|
137 | |
---|
138 | $reader = new AnnotationReader(); |
---|
139 | $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); |
---|
140 | $reader->setIgnoreNotImportedAnnotations(true); |
---|
141 | $reader->setEnableParsePhpImports(false); |
---|
142 | $reader = new \Doctrine\Common\Annotations\CachedReader( |
---|
143 | new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache() |
---|
144 | ); |
---|
145 | } else { |
---|
146 | $reader = new AnnotationReader(); |
---|
147 | $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); |
---|
148 | } |
---|
149 | return new AnnotationDriver($reader, (array)$paths); |
---|
150 | } |
---|
151 | |
---|
152 | /** |
---|
153 | * Adds a namespace under a certain alias. |
---|
154 | * |
---|
155 | * @param string $alias |
---|
156 | * @param string $namespace |
---|
157 | */ |
---|
158 | public function addEntityNamespace($alias, $namespace) |
---|
159 | { |
---|
160 | $this->_attributes['entityNamespaces'][$alias] = $namespace; |
---|
161 | } |
---|
162 | |
---|
163 | /** |
---|
164 | * Resolves a registered namespace alias to the full namespace. |
---|
165 | * |
---|
166 | * @param string $entityNamespaceAlias |
---|
167 | * @return string |
---|
168 | * @throws MappingException |
---|
169 | */ |
---|
170 | public function getEntityNamespace($entityNamespaceAlias) |
---|
171 | { |
---|
172 | if ( ! isset($this->_attributes['entityNamespaces'][$entityNamespaceAlias])) { |
---|
173 | throw ORMException::unknownEntityNamespace($entityNamespaceAlias); |
---|
174 | } |
---|
175 | |
---|
176 | return trim($this->_attributes['entityNamespaces'][$entityNamespaceAlias], '\\'); |
---|
177 | } |
---|
178 | |
---|
179 | /** |
---|
180 | * Set the entity alias map |
---|
181 | * |
---|
182 | * @param array $entityAliasMap |
---|
183 | * @return void |
---|
184 | */ |
---|
185 | public function setEntityNamespaces(array $entityNamespaces) |
---|
186 | { |
---|
187 | $this->_attributes['entityNamespaces'] = $entityNamespaces; |
---|
188 | } |
---|
189 | |
---|
190 | /** |
---|
191 | * Retrieves the list of registered entity namespace aliases. |
---|
192 | * |
---|
193 | * @return array |
---|
194 | */ |
---|
195 | public function getEntityNamespaces() |
---|
196 | { |
---|
197 | return $this->_attributes['entityNamespaces']; |
---|
198 | } |
---|
199 | |
---|
200 | /** |
---|
201 | * Gets the cache driver implementation that is used for the mapping metadata. |
---|
202 | * |
---|
203 | * @throws ORMException |
---|
204 | * @return Mapping\Driver\Driver |
---|
205 | */ |
---|
206 | public function getMetadataDriverImpl() |
---|
207 | { |
---|
208 | return isset($this->_attributes['metadataDriverImpl']) ? |
---|
209 | $this->_attributes['metadataDriverImpl'] : null; |
---|
210 | } |
---|
211 | |
---|
212 | /** |
---|
213 | * Gets the cache driver implementation that is used for the query cache (SQL cache). |
---|
214 | * |
---|
215 | * @return \Doctrine\Common\Cache\Cache |
---|
216 | */ |
---|
217 | public function getQueryCacheImpl() |
---|
218 | { |
---|
219 | return isset($this->_attributes['queryCacheImpl']) ? |
---|
220 | $this->_attributes['queryCacheImpl'] : null; |
---|
221 | } |
---|
222 | |
---|
223 | /** |
---|
224 | * Sets the cache driver implementation that is used for the query cache (SQL cache). |
---|
225 | * |
---|
226 | * @param \Doctrine\Common\Cache\Cache $cacheImpl |
---|
227 | */ |
---|
228 | public function setQueryCacheImpl(Cache $cacheImpl) |
---|
229 | { |
---|
230 | $this->_attributes['queryCacheImpl'] = $cacheImpl; |
---|
231 | } |
---|
232 | |
---|
233 | /** |
---|
234 | * Gets the cache driver implementation that is used for the hydration cache (SQL cache). |
---|
235 | * |
---|
236 | * @return \Doctrine\Common\Cache\Cache |
---|
237 | */ |
---|
238 | public function getHydrationCacheImpl() |
---|
239 | { |
---|
240 | return isset($this->_attributes['hydrationCacheImpl']) |
---|
241 | ? $this->_attributes['hydrationCacheImpl'] |
---|
242 | : null; |
---|
243 | } |
---|
244 | |
---|
245 | /** |
---|
246 | * Sets the cache driver implementation that is used for the hydration cache (SQL cache). |
---|
247 | * |
---|
248 | * @param \Doctrine\Common\Cache\Cache $cacheImpl |
---|
249 | */ |
---|
250 | public function setHydrationCacheImpl(Cache $cacheImpl) |
---|
251 | { |
---|
252 | $this->_attributes['hydrationCacheImpl'] = $cacheImpl; |
---|
253 | } |
---|
254 | |
---|
255 | /** |
---|
256 | * Gets the cache driver implementation that is used for metadata caching. |
---|
257 | * |
---|
258 | * @return \Doctrine\Common\Cache\Cache |
---|
259 | */ |
---|
260 | public function getMetadataCacheImpl() |
---|
261 | { |
---|
262 | return isset($this->_attributes['metadataCacheImpl']) ? |
---|
263 | $this->_attributes['metadataCacheImpl'] : null; |
---|
264 | } |
---|
265 | |
---|
266 | /** |
---|
267 | * Sets the cache driver implementation that is used for metadata caching. |
---|
268 | * |
---|
269 | * @param \Doctrine\Common\Cache\Cache $cacheImpl |
---|
270 | */ |
---|
271 | public function setMetadataCacheImpl(Cache $cacheImpl) |
---|
272 | { |
---|
273 | $this->_attributes['metadataCacheImpl'] = $cacheImpl; |
---|
274 | } |
---|
275 | |
---|
276 | /** |
---|
277 | * Adds a named DQL query to the configuration. |
---|
278 | * |
---|
279 | * @param string $name The name of the query. |
---|
280 | * @param string $dql The DQL query string. |
---|
281 | */ |
---|
282 | public function addNamedQuery($name, $dql) |
---|
283 | { |
---|
284 | $this->_attributes['namedQueries'][$name] = $dql; |
---|
285 | } |
---|
286 | |
---|
287 | /** |
---|
288 | * Gets a previously registered named DQL query. |
---|
289 | * |
---|
290 | * @param string $name The name of the query. |
---|
291 | * @return string The DQL query. |
---|
292 | */ |
---|
293 | public function getNamedQuery($name) |
---|
294 | { |
---|
295 | if ( ! isset($this->_attributes['namedQueries'][$name])) { |
---|
296 | throw ORMException::namedQueryNotFound($name); |
---|
297 | } |
---|
298 | return $this->_attributes['namedQueries'][$name]; |
---|
299 | } |
---|
300 | |
---|
301 | /** |
---|
302 | * Adds a named native query to the configuration. |
---|
303 | * |
---|
304 | * @param string $name The name of the query. |
---|
305 | * @param string $sql The native SQL query string. |
---|
306 | * @param ResultSetMapping $rsm The ResultSetMapping used for the results of the SQL query. |
---|
307 | */ |
---|
308 | public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm) |
---|
309 | { |
---|
310 | $this->_attributes['namedNativeQueries'][$name] = array($sql, $rsm); |
---|
311 | } |
---|
312 | |
---|
313 | /** |
---|
314 | * Gets the components of a previously registered named native query. |
---|
315 | * |
---|
316 | * @param string $name The name of the query. |
---|
317 | * @return array A tuple with the first element being the SQL string and the second |
---|
318 | * element being the ResultSetMapping. |
---|
319 | */ |
---|
320 | public function getNamedNativeQuery($name) |
---|
321 | { |
---|
322 | if ( ! isset($this->_attributes['namedNativeQueries'][$name])) { |
---|
323 | throw ORMException::namedNativeQueryNotFound($name); |
---|
324 | } |
---|
325 | return $this->_attributes['namedNativeQueries'][$name]; |
---|
326 | } |
---|
327 | |
---|
328 | /** |
---|
329 | * Ensures that this Configuration instance contains settings that are |
---|
330 | * suitable for a production environment. |
---|
331 | * |
---|
332 | * @throws ORMException If a configuration setting has a value that is not |
---|
333 | * suitable for a production environment. |
---|
334 | */ |
---|
335 | public function ensureProductionSettings() |
---|
336 | { |
---|
337 | if ( !$this->getQueryCacheImpl()) { |
---|
338 | throw ORMException::queryCacheNotConfigured(); |
---|
339 | } |
---|
340 | if ( !$this->getMetadataCacheImpl()) { |
---|
341 | throw ORMException::metadataCacheNotConfigured(); |
---|
342 | } |
---|
343 | if ($this->getAutoGenerateProxyClasses()) { |
---|
344 | throw ORMException::proxyClassesAlwaysRegenerating(); |
---|
345 | } |
---|
346 | } |
---|
347 | |
---|
348 | /** |
---|
349 | * Registers a custom DQL function that produces a string value. |
---|
350 | * Such a function can then be used in any DQL statement in any place where string |
---|
351 | * functions are allowed. |
---|
352 | * |
---|
353 | * DQL function names are case-insensitive. |
---|
354 | * |
---|
355 | * @param string $name |
---|
356 | * @param string $className |
---|
357 | */ |
---|
358 | public function addCustomStringFunction($name, $className) |
---|
359 | { |
---|
360 | $this->_attributes['customStringFunctions'][strtolower($name)] = $className; |
---|
361 | } |
---|
362 | |
---|
363 | /** |
---|
364 | * Gets the implementation class name of a registered custom string DQL function. |
---|
365 | * |
---|
366 | * @param string $name |
---|
367 | * @return string |
---|
368 | */ |
---|
369 | public function getCustomStringFunction($name) |
---|
370 | { |
---|
371 | $name = strtolower($name); |
---|
372 | return isset($this->_attributes['customStringFunctions'][$name]) ? |
---|
373 | $this->_attributes['customStringFunctions'][$name] : null; |
---|
374 | } |
---|
375 | |
---|
376 | /** |
---|
377 | * Sets a map of custom DQL string functions. |
---|
378 | * |
---|
379 | * Keys must be function names and values the FQCN of the implementing class. |
---|
380 | * The function names will be case-insensitive in DQL. |
---|
381 | * |
---|
382 | * Any previously added string functions are discarded. |
---|
383 | * |
---|
384 | * @param array $functions The map of custom DQL string functions. |
---|
385 | */ |
---|
386 | public function setCustomStringFunctions(array $functions) |
---|
387 | { |
---|
388 | $this->_attributes['customStringFunctions'] = array_change_key_case($functions); |
---|
389 | } |
---|
390 | |
---|
391 | /** |
---|
392 | * Registers a custom DQL function that produces a numeric value. |
---|
393 | * Such a function can then be used in any DQL statement in any place where numeric |
---|
394 | * functions are allowed. |
---|
395 | * |
---|
396 | * DQL function names are case-insensitive. |
---|
397 | * |
---|
398 | * @param string $name |
---|
399 | * @param string $className |
---|
400 | */ |
---|
401 | public function addCustomNumericFunction($name, $className) |
---|
402 | { |
---|
403 | $this->_attributes['customNumericFunctions'][strtolower($name)] = $className; |
---|
404 | } |
---|
405 | |
---|
406 | /** |
---|
407 | * Gets the implementation class name of a registered custom numeric DQL function. |
---|
408 | * |
---|
409 | * @param string $name |
---|
410 | * @return string |
---|
411 | */ |
---|
412 | public function getCustomNumericFunction($name) |
---|
413 | { |
---|
414 | $name = strtolower($name); |
---|
415 | return isset($this->_attributes['customNumericFunctions'][$name]) ? |
---|
416 | $this->_attributes['customNumericFunctions'][$name] : null; |
---|
417 | } |
---|
418 | |
---|
419 | /** |
---|
420 | * Sets a map of custom DQL numeric functions. |
---|
421 | * |
---|
422 | * Keys must be function names and values the FQCN of the implementing class. |
---|
423 | * The function names will be case-insensitive in DQL. |
---|
424 | * |
---|
425 | * Any previously added numeric functions are discarded. |
---|
426 | * |
---|
427 | * @param array $functions The map of custom DQL numeric functions. |
---|
428 | */ |
---|
429 | public function setCustomNumericFunctions(array $functions) |
---|
430 | { |
---|
431 | $this->_attributes['customNumericFunctions'] = array_change_key_case($functions); |
---|
432 | } |
---|
433 | |
---|
434 | /** |
---|
435 | * Registers a custom DQL function that produces a date/time value. |
---|
436 | * Such a function can then be used in any DQL statement in any place where date/time |
---|
437 | * functions are allowed. |
---|
438 | * |
---|
439 | * DQL function names are case-insensitive. |
---|
440 | * |
---|
441 | * @param string $name |
---|
442 | * @param string $className |
---|
443 | */ |
---|
444 | public function addCustomDatetimeFunction($name, $className) |
---|
445 | { |
---|
446 | $this->_attributes['customDatetimeFunctions'][strtolower($name)] = $className; |
---|
447 | } |
---|
448 | |
---|
449 | /** |
---|
450 | * Gets the implementation class name of a registered custom date/time DQL function. |
---|
451 | * |
---|
452 | * @param string $name |
---|
453 | * @return string |
---|
454 | */ |
---|
455 | public function getCustomDatetimeFunction($name) |
---|
456 | { |
---|
457 | $name = strtolower($name); |
---|
458 | return isset($this->_attributes['customDatetimeFunctions'][$name]) ? |
---|
459 | $this->_attributes['customDatetimeFunctions'][$name] : null; |
---|
460 | } |
---|
461 | |
---|
462 | /** |
---|
463 | * Sets a map of custom DQL date/time functions. |
---|
464 | * |
---|
465 | * Keys must be function names and values the FQCN of the implementing class. |
---|
466 | * The function names will be case-insensitive in DQL. |
---|
467 | * |
---|
468 | * Any previously added date/time functions are discarded. |
---|
469 | * |
---|
470 | * @param array $functions The map of custom DQL date/time functions. |
---|
471 | */ |
---|
472 | public function setCustomDatetimeFunctions(array $functions) |
---|
473 | { |
---|
474 | $this->_attributes['customDatetimeFunctions'] = array_change_key_case($functions); |
---|
475 | } |
---|
476 | |
---|
477 | /** |
---|
478 | * Get the hydrator class for the given hydration mode name. |
---|
479 | * |
---|
480 | * @param string $modeName The hydration mode name. |
---|
481 | * @return string $hydrator The hydrator class name. |
---|
482 | */ |
---|
483 | public function getCustomHydrationMode($modeName) |
---|
484 | { |
---|
485 | return isset($this->_attributes['customHydrationModes'][$modeName]) ? |
---|
486 | $this->_attributes['customHydrationModes'][$modeName] : null; |
---|
487 | } |
---|
488 | |
---|
489 | /** |
---|
490 | * Add a custom hydration mode. |
---|
491 | * |
---|
492 | * @param string $modeName The hydration mode name. |
---|
493 | * @param string $hydrator The hydrator class name. |
---|
494 | */ |
---|
495 | public function addCustomHydrationMode($modeName, $hydrator) |
---|
496 | { |
---|
497 | $this->_attributes['customHydrationModes'][$modeName] = $hydrator; |
---|
498 | } |
---|
499 | |
---|
500 | /** |
---|
501 | * Set a class metadata factory. |
---|
502 | * |
---|
503 | * @param string $cmf |
---|
504 | */ |
---|
505 | public function setClassMetadataFactoryName($cmfName) |
---|
506 | { |
---|
507 | $this->_attributes['classMetadataFactoryName'] = $cmfName; |
---|
508 | } |
---|
509 | |
---|
510 | /** |
---|
511 | * @return string |
---|
512 | */ |
---|
513 | public function getClassMetadataFactoryName() |
---|
514 | { |
---|
515 | if (!isset($this->_attributes['classMetadataFactoryName'])) { |
---|
516 | $this->_attributes['classMetadataFactoryName'] = 'Doctrine\ORM\Mapping\ClassMetadataFactory'; |
---|
517 | } |
---|
518 | return $this->_attributes['classMetadataFactoryName']; |
---|
519 | } |
---|
520 | |
---|
521 | /** |
---|
522 | * Add a filter to the list of possible filters. |
---|
523 | * |
---|
524 | * @param string $name The name of the filter. |
---|
525 | * @param string $className The class name of the filter. |
---|
526 | */ |
---|
527 | public function addFilter($name, $className) |
---|
528 | { |
---|
529 | $this->_attributes['filters'][$name] = $className; |
---|
530 | } |
---|
531 | |
---|
532 | /** |
---|
533 | * Gets the class name for a given filter name. |
---|
534 | * |
---|
535 | * @param string $name The name of the filter. |
---|
536 | * |
---|
537 | * @return string The class name of the filter, or null of it is not |
---|
538 | * defined. |
---|
539 | */ |
---|
540 | public function getFilterClassName($name) |
---|
541 | { |
---|
542 | return isset($this->_attributes['filters'][$name]) ? |
---|
543 | $this->_attributes['filters'][$name] : null; |
---|
544 | } |
---|
545 | |
---|
546 | /** |
---|
547 | * Set default repository class. |
---|
548 | * |
---|
549 | * @since 2.2 |
---|
550 | * @param string $className |
---|
551 | * @throws ORMException If not is a \Doctrine\ORM\EntityRepository |
---|
552 | */ |
---|
553 | public function setDefaultRepositoryClassName($className) |
---|
554 | { |
---|
555 | if ($className != "Doctrine\ORM\EntityRepository" && |
---|
556 | !is_subclass_of($className, 'Doctrine\ORM\EntityRepository')){ |
---|
557 | throw ORMException::invalidEntityRepository($className); |
---|
558 | } |
---|
559 | $this->_attributes['defaultRepositoryClassName'] = $className; |
---|
560 | } |
---|
561 | |
---|
562 | /** |
---|
563 | * Get default repository class. |
---|
564 | * |
---|
565 | * @since 2.2 |
---|
566 | * @return string |
---|
567 | */ |
---|
568 | public function getDefaultRepositoryClassName() |
---|
569 | { |
---|
570 | return isset($this->_attributes['defaultRepositoryClassName']) ? |
---|
571 | $this->_attributes['defaultRepositoryClassName'] : 'Doctrine\ORM\EntityRepository'; |
---|
572 | } |
---|
573 | } |
---|