Configuration.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  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. namespace Doctrine\ORM;
  20. use Doctrine\Common\Annotations\AnnotationReader;
  21. use Doctrine\Common\Annotations\AnnotationRegistry;
  22. use Doctrine\Common\Annotations\CachedReader;
  23. use Doctrine\Common\Annotations\SimpleAnnotationReader;
  24. use Doctrine\Common\Cache\ArrayCache;
  25. use Doctrine\Common\Cache\Cache;
  26. use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
  27. use Doctrine\ORM\Mapping\DefaultEntityListenerResolver;
  28. use Doctrine\ORM\Mapping\DefaultNamingStrategy;
  29. use Doctrine\ORM\Mapping\DefaultQuoteStrategy;
  30. use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
  31. use Doctrine\ORM\Mapping\EntityListenerResolver;
  32. use Doctrine\ORM\Mapping\NamingStrategy;
  33. use Doctrine\ORM\Mapping\QuoteStrategy;
  34. use Doctrine\ORM\Repository\DefaultRepositoryFactory;
  35. use Doctrine\ORM\Repository\RepositoryFactory;
  36. /**
  37. * Configuration container for all configuration options of Doctrine.
  38. * It combines all configuration options from DBAL & ORM.
  39. *
  40. * @since 2.0
  41. * @internal When adding a new configuration option just write a getter/setter pair.
  42. * @author Benjamin Eberlei <kontakt@beberlei.de>
  43. * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
  44. * @author Jonathan Wage <jonwage@gmail.com>
  45. * @author Roman Borschel <roman@code-factory.org>
  46. */
  47. class Configuration extends \Doctrine\DBAL\Configuration
  48. {
  49. /**
  50. * Sets the directory where Doctrine generates any necessary proxy class files.
  51. *
  52. * @param string $dir
  53. *
  54. * @return void
  55. */
  56. public function setProxyDir($dir)
  57. {
  58. $this->_attributes['proxyDir'] = $dir;
  59. }
  60. /**
  61. * Gets the directory where Doctrine generates any necessary proxy class files.
  62. *
  63. * @return string|null
  64. */
  65. public function getProxyDir()
  66. {
  67. return isset($this->_attributes['proxyDir'])
  68. ? $this->_attributes['proxyDir']
  69. : null;
  70. }
  71. /**
  72. * Gets a boolean flag that indicates whether proxy classes should always be regenerated
  73. * during each script execution.
  74. *
  75. * @return boolean
  76. */
  77. public function getAutoGenerateProxyClasses()
  78. {
  79. return isset($this->_attributes['autoGenerateProxyClasses'])
  80. ? $this->_attributes['autoGenerateProxyClasses']
  81. : true;
  82. }
  83. /**
  84. * Sets a boolean flag that indicates whether proxy classes should always be regenerated
  85. * during each script execution.
  86. *
  87. * @param boolean $bool
  88. *
  89. * @return void
  90. */
  91. public function setAutoGenerateProxyClasses($bool)
  92. {
  93. $this->_attributes['autoGenerateProxyClasses'] = $bool;
  94. }
  95. /**
  96. * Gets the namespace where proxy classes reside.
  97. *
  98. * @return string|null
  99. */
  100. public function getProxyNamespace()
  101. {
  102. return isset($this->_attributes['proxyNamespace'])
  103. ? $this->_attributes['proxyNamespace']
  104. : null;
  105. }
  106. /**
  107. * Sets the namespace where proxy classes reside.
  108. *
  109. * @param string $ns
  110. *
  111. * @return void
  112. */
  113. public function setProxyNamespace($ns)
  114. {
  115. $this->_attributes['proxyNamespace'] = $ns;
  116. }
  117. /**
  118. * Sets the cache driver implementation that is used for metadata caching.
  119. *
  120. * @param MappingDriver $driverImpl
  121. *
  122. * @return void
  123. *
  124. * @todo Force parameter to be a Closure to ensure lazy evaluation
  125. * (as soon as a metadata cache is in effect, the driver never needs to initialize).
  126. */
  127. public function setMetadataDriverImpl(MappingDriver $driverImpl)
  128. {
  129. $this->_attributes['metadataDriverImpl'] = $driverImpl;
  130. }
  131. /**
  132. * Adds a new default annotation driver with a correctly configured annotation reader. If $useSimpleAnnotationReader
  133. * is true, the notation `@Entity` will work, otherwise, the notation `@ORM\Entity` will be supported.
  134. *
  135. * @param array $paths
  136. * @param bool $useSimpleAnnotationReader
  137. *
  138. * @return AnnotationDriver
  139. */
  140. public function newDefaultAnnotationDriver($paths = array(), $useSimpleAnnotationReader = true)
  141. {
  142. AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php');
  143. if ($useSimpleAnnotationReader) {
  144. // Register the ORM Annotations in the AnnotationRegistry
  145. $reader = new SimpleAnnotationReader();
  146. $reader->addNamespace('Doctrine\ORM\Mapping');
  147. $cachedReader = new CachedReader($reader, new ArrayCache());
  148. return new AnnotationDriver($cachedReader, (array) $paths);
  149. }
  150. return new AnnotationDriver(
  151. new CachedReader(new AnnotationReader(), new ArrayCache()),
  152. (array) $paths
  153. );
  154. }
  155. /**
  156. * Adds a namespace under a certain alias.
  157. *
  158. * @param string $alias
  159. * @param string $namespace
  160. *
  161. * @return void
  162. */
  163. public function addEntityNamespace($alias, $namespace)
  164. {
  165. $this->_attributes['entityNamespaces'][$alias] = $namespace;
  166. }
  167. /**
  168. * Resolves a registered namespace alias to the full namespace.
  169. *
  170. * @param string $entityNamespaceAlias
  171. *
  172. * @return string
  173. *
  174. * @throws ORMException
  175. */
  176. public function getEntityNamespace($entityNamespaceAlias)
  177. {
  178. if ( ! isset($this->_attributes['entityNamespaces'][$entityNamespaceAlias])) {
  179. throw ORMException::unknownEntityNamespace($entityNamespaceAlias);
  180. }
  181. return trim($this->_attributes['entityNamespaces'][$entityNamespaceAlias], '\\');
  182. }
  183. /**
  184. * Sets the entity alias map.
  185. *
  186. * @param array $entityNamespaces
  187. *
  188. * @return void
  189. */
  190. public function setEntityNamespaces(array $entityNamespaces)
  191. {
  192. $this->_attributes['entityNamespaces'] = $entityNamespaces;
  193. }
  194. /**
  195. * Retrieves the list of registered entity namespace aliases.
  196. *
  197. * @return array
  198. */
  199. public function getEntityNamespaces()
  200. {
  201. return $this->_attributes['entityNamespaces'];
  202. }
  203. /**
  204. * Gets the cache driver implementation that is used for the mapping metadata.
  205. *
  206. * @return MappingDriver|null
  207. *
  208. * @throws ORMException
  209. */
  210. public function getMetadataDriverImpl()
  211. {
  212. return isset($this->_attributes['metadataDriverImpl'])
  213. ? $this->_attributes['metadataDriverImpl']
  214. : null;
  215. }
  216. /**
  217. * Gets the cache driver implementation that is used for the query cache (SQL cache).
  218. *
  219. * @return \Doctrine\Common\Cache\Cache|null
  220. */
  221. public function getQueryCacheImpl()
  222. {
  223. return isset($this->_attributes['queryCacheImpl'])
  224. ? $this->_attributes['queryCacheImpl']
  225. : null;
  226. }
  227. /**
  228. * Sets the cache driver implementation that is used for the query cache (SQL cache).
  229. *
  230. * @param \Doctrine\Common\Cache\Cache $cacheImpl
  231. *
  232. * @return void
  233. */
  234. public function setQueryCacheImpl(Cache $cacheImpl)
  235. {
  236. $this->_attributes['queryCacheImpl'] = $cacheImpl;
  237. }
  238. /**
  239. * Gets the cache driver implementation that is used for the hydration cache (SQL cache).
  240. *
  241. * @return \Doctrine\Common\Cache\Cache|null
  242. */
  243. public function getHydrationCacheImpl()
  244. {
  245. return isset($this->_attributes['hydrationCacheImpl'])
  246. ? $this->_attributes['hydrationCacheImpl']
  247. : null;
  248. }
  249. /**
  250. * Sets the cache driver implementation that is used for the hydration cache (SQL cache).
  251. *
  252. * @param \Doctrine\Common\Cache\Cache $cacheImpl
  253. *
  254. * @return void
  255. */
  256. public function setHydrationCacheImpl(Cache $cacheImpl)
  257. {
  258. $this->_attributes['hydrationCacheImpl'] = $cacheImpl;
  259. }
  260. /**
  261. * Gets the cache driver implementation that is used for metadata caching.
  262. *
  263. * @return \Doctrine\Common\Cache\Cache|null
  264. */
  265. public function getMetadataCacheImpl()
  266. {
  267. return isset($this->_attributes['metadataCacheImpl'])
  268. ? $this->_attributes['metadataCacheImpl']
  269. : null;
  270. }
  271. /**
  272. * Sets the cache driver implementation that is used for metadata caching.
  273. *
  274. * @param \Doctrine\Common\Cache\Cache $cacheImpl
  275. *
  276. * @return void
  277. */
  278. public function setMetadataCacheImpl(Cache $cacheImpl)
  279. {
  280. $this->_attributes['metadataCacheImpl'] = $cacheImpl;
  281. }
  282. /**
  283. * Adds a named DQL query to the configuration.
  284. *
  285. * @param string $name The name of the query.
  286. * @param string $dql The DQL query string.
  287. *
  288. * @return void
  289. */
  290. public function addNamedQuery($name, $dql)
  291. {
  292. $this->_attributes['namedQueries'][$name] = $dql;
  293. }
  294. /**
  295. * Gets a previously registered named DQL query.
  296. *
  297. * @param string $name The name of the query.
  298. *
  299. * @return string The DQL query.
  300. *
  301. * @throws ORMException
  302. */
  303. public function getNamedQuery($name)
  304. {
  305. if ( ! isset($this->_attributes['namedQueries'][$name])) {
  306. throw ORMException::namedQueryNotFound($name);
  307. }
  308. return $this->_attributes['namedQueries'][$name];
  309. }
  310. /**
  311. * Adds a named native query to the configuration.
  312. *
  313. * @param string $name The name of the query.
  314. * @param string $sql The native SQL query string.
  315. * @param Query\ResultSetMapping $rsm The ResultSetMapping used for the results of the SQL query.
  316. *
  317. * @return void
  318. */
  319. public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm)
  320. {
  321. $this->_attributes['namedNativeQueries'][$name] = array($sql, $rsm);
  322. }
  323. /**
  324. * Gets the components of a previously registered named native query.
  325. *
  326. * @param string $name The name of the query.
  327. *
  328. * @return array A tuple with the first element being the SQL string and the second
  329. * element being the ResultSetMapping.
  330. *
  331. * @throws ORMException
  332. */
  333. public function getNamedNativeQuery($name)
  334. {
  335. if ( ! isset($this->_attributes['namedNativeQueries'][$name])) {
  336. throw ORMException::namedNativeQueryNotFound($name);
  337. }
  338. return $this->_attributes['namedNativeQueries'][$name];
  339. }
  340. /**
  341. * Ensures that this Configuration instance contains settings that are
  342. * suitable for a production environment.
  343. *
  344. * @return void
  345. *
  346. * @throws ORMException If a configuration setting has a value that is not
  347. * suitable for a production environment.
  348. */
  349. public function ensureProductionSettings()
  350. {
  351. if ( ! $this->getQueryCacheImpl()) {
  352. throw ORMException::queryCacheNotConfigured();
  353. }
  354. if ( ! $this->getMetadataCacheImpl()) {
  355. throw ORMException::metadataCacheNotConfigured();
  356. }
  357. if ($this->getAutoGenerateProxyClasses()) {
  358. throw ORMException::proxyClassesAlwaysRegenerating();
  359. }
  360. }
  361. /**
  362. * Registers a custom DQL function that produces a string value.
  363. * Such a function can then be used in any DQL statement in any place where string
  364. * functions are allowed.
  365. *
  366. * DQL function names are case-insensitive.
  367. *
  368. * @param string $name
  369. * @param string $className
  370. *
  371. * @return void
  372. *
  373. * @throws ORMException
  374. */
  375. public function addCustomStringFunction($name, $className)
  376. {
  377. if (Query\Parser::isInternalFunction($name)) {
  378. throw ORMException::overwriteInternalDQLFunctionNotAllowed($name);
  379. }
  380. $this->_attributes['customStringFunctions'][strtolower($name)] = $className;
  381. }
  382. /**
  383. * Gets the implementation class name of a registered custom string DQL function.
  384. *
  385. * @param string $name
  386. *
  387. * @return string|null
  388. */
  389. public function getCustomStringFunction($name)
  390. {
  391. $name = strtolower($name);
  392. return isset($this->_attributes['customStringFunctions'][$name])
  393. ? $this->_attributes['customStringFunctions'][$name]
  394. : null;
  395. }
  396. /**
  397. * Sets a map of custom DQL string functions.
  398. *
  399. * Keys must be function names and values the FQCN of the implementing class.
  400. * The function names will be case-insensitive in DQL.
  401. *
  402. * Any previously added string functions are discarded.
  403. *
  404. * @param array $functions The map of custom DQL string functions.
  405. *
  406. * @return void
  407. */
  408. public function setCustomStringFunctions(array $functions)
  409. {
  410. foreach ($functions as $name => $className) {
  411. $this->addCustomStringFunction($name, $className);
  412. }
  413. }
  414. /**
  415. * Registers a custom DQL function that produces a numeric value.
  416. * Such a function can then be used in any DQL statement in any place where numeric
  417. * functions are allowed.
  418. *
  419. * DQL function names are case-insensitive.
  420. *
  421. * @param string $name
  422. * @param string $className
  423. *
  424. * @return void
  425. *
  426. * @throws ORMException
  427. */
  428. public function addCustomNumericFunction($name, $className)
  429. {
  430. if (Query\Parser::isInternalFunction($name)) {
  431. throw ORMException::overwriteInternalDQLFunctionNotAllowed($name);
  432. }
  433. $this->_attributes['customNumericFunctions'][strtolower($name)] = $className;
  434. }
  435. /**
  436. * Gets the implementation class name of a registered custom numeric DQL function.
  437. *
  438. * @param string $name
  439. *
  440. * @return string|null
  441. */
  442. public function getCustomNumericFunction($name)
  443. {
  444. $name = strtolower($name);
  445. return isset($this->_attributes['customNumericFunctions'][$name])
  446. ? $this->_attributes['customNumericFunctions'][$name]
  447. : null;
  448. }
  449. /**
  450. * Sets a map of custom DQL numeric functions.
  451. *
  452. * Keys must be function names and values the FQCN of the implementing class.
  453. * The function names will be case-insensitive in DQL.
  454. *
  455. * Any previously added numeric functions are discarded.
  456. *
  457. * @param array $functions The map of custom DQL numeric functions.
  458. *
  459. * @return void
  460. */
  461. public function setCustomNumericFunctions(array $functions)
  462. {
  463. foreach ($functions as $name => $className) {
  464. $this->addCustomNumericFunction($name, $className);
  465. }
  466. }
  467. /**
  468. * Registers a custom DQL function that produces a date/time value.
  469. * Such a function can then be used in any DQL statement in any place where date/time
  470. * functions are allowed.
  471. *
  472. * DQL function names are case-insensitive.
  473. *
  474. * @param string $name
  475. * @param string $className
  476. *
  477. * @return void
  478. *
  479. * @throws ORMException
  480. */
  481. public function addCustomDatetimeFunction($name, $className)
  482. {
  483. if (Query\Parser::isInternalFunction($name)) {
  484. throw ORMException::overwriteInternalDQLFunctionNotAllowed($name);
  485. }
  486. $this->_attributes['customDatetimeFunctions'][strtolower($name)] = $className;
  487. }
  488. /**
  489. * Gets the implementation class name of a registered custom date/time DQL function.
  490. *
  491. * @param string $name
  492. *
  493. * @return string|null
  494. */
  495. public function getCustomDatetimeFunction($name)
  496. {
  497. $name = strtolower($name);
  498. return isset($this->_attributes['customDatetimeFunctions'][$name])
  499. ? $this->_attributes['customDatetimeFunctions'][$name]
  500. : null;
  501. }
  502. /**
  503. * Sets a map of custom DQL date/time functions.
  504. *
  505. * Keys must be function names and values the FQCN of the implementing class.
  506. * The function names will be case-insensitive in DQL.
  507. *
  508. * Any previously added date/time functions are discarded.
  509. *
  510. * @param array $functions The map of custom DQL date/time functions.
  511. *
  512. * @return void
  513. */
  514. public function setCustomDatetimeFunctions(array $functions)
  515. {
  516. foreach ($functions as $name => $className) {
  517. $this->addCustomDatetimeFunction($name, $className);
  518. }
  519. }
  520. /**
  521. * Sets the custom hydrator modes in one pass.
  522. *
  523. * @param array $modes An array of ($modeName => $hydrator).
  524. *
  525. * @return void
  526. */
  527. public function setCustomHydrationModes($modes)
  528. {
  529. $this->_attributes['customHydrationModes'] = array();
  530. foreach ($modes as $modeName => $hydrator) {
  531. $this->addCustomHydrationMode($modeName, $hydrator);
  532. }
  533. }
  534. /**
  535. * Gets the hydrator class for the given hydration mode name.
  536. *
  537. * @param string $modeName The hydration mode name.
  538. *
  539. * @return string|null The hydrator class name.
  540. */
  541. public function getCustomHydrationMode($modeName)
  542. {
  543. return isset($this->_attributes['customHydrationModes'][$modeName])
  544. ? $this->_attributes['customHydrationModes'][$modeName]
  545. : null;
  546. }
  547. /**
  548. * Adds a custom hydration mode.
  549. *
  550. * @param string $modeName The hydration mode name.
  551. * @param string $hydrator The hydrator class name.
  552. *
  553. * @return void
  554. */
  555. public function addCustomHydrationMode($modeName, $hydrator)
  556. {
  557. $this->_attributes['customHydrationModes'][$modeName] = $hydrator;
  558. }
  559. /**
  560. * Sets a class metadata factory.
  561. *
  562. * @param string $cmfName
  563. *
  564. * @return void
  565. */
  566. public function setClassMetadataFactoryName($cmfName)
  567. {
  568. $this->_attributes['classMetadataFactoryName'] = $cmfName;
  569. }
  570. /**
  571. * @return string
  572. */
  573. public function getClassMetadataFactoryName()
  574. {
  575. if ( ! isset($this->_attributes['classMetadataFactoryName'])) {
  576. $this->_attributes['classMetadataFactoryName'] = 'Doctrine\ORM\Mapping\ClassMetadataFactory';
  577. }
  578. return $this->_attributes['classMetadataFactoryName'];
  579. }
  580. /**
  581. * Adds a filter to the list of possible filters.
  582. *
  583. * @param string $name The name of the filter.
  584. * @param string $className The class name of the filter.
  585. */
  586. public function addFilter($name, $className)
  587. {
  588. $this->_attributes['filters'][$name] = $className;
  589. }
  590. /**
  591. * Gets the class name for a given filter name.
  592. *
  593. * @param string $name The name of the filter.
  594. *
  595. * @return string The class name of the filter, or null of it is not
  596. * defined.
  597. */
  598. public function getFilterClassName($name)
  599. {
  600. return isset($this->_attributes['filters'][$name])
  601. ? $this->_attributes['filters'][$name]
  602. : null;
  603. }
  604. /**
  605. * Sets default repository class.
  606. *
  607. * @since 2.2
  608. *
  609. * @param string $className
  610. *
  611. * @return void
  612. *
  613. * @throws ORMException If not is a \Doctrine\Common\Persistence\ObjectRepository
  614. */
  615. public function setDefaultRepositoryClassName($className)
  616. {
  617. $reflectionClass = new \ReflectionClass($className);
  618. if ( ! $reflectionClass->implementsInterface('Doctrine\Common\Persistence\ObjectRepository')) {
  619. throw ORMException::invalidEntityRepository($className);
  620. }
  621. $this->_attributes['defaultRepositoryClassName'] = $className;
  622. }
  623. /**
  624. * Get default repository class.
  625. *
  626. * @since 2.2
  627. *
  628. * @return string
  629. */
  630. public function getDefaultRepositoryClassName()
  631. {
  632. return isset($this->_attributes['defaultRepositoryClassName'])
  633. ? $this->_attributes['defaultRepositoryClassName']
  634. : 'Doctrine\ORM\EntityRepository';
  635. }
  636. /**
  637. * Sets naming strategy.
  638. *
  639. * @since 2.3
  640. *
  641. * @param NamingStrategy $namingStrategy
  642. *
  643. * @return void
  644. */
  645. public function setNamingStrategy(NamingStrategy $namingStrategy)
  646. {
  647. $this->_attributes['namingStrategy'] = $namingStrategy;
  648. }
  649. /**
  650. * Gets naming strategy..
  651. *
  652. * @since 2.3
  653. *
  654. * @return NamingStrategy
  655. */
  656. public function getNamingStrategy()
  657. {
  658. if ( ! isset($this->_attributes['namingStrategy'])) {
  659. $this->_attributes['namingStrategy'] = new DefaultNamingStrategy();
  660. }
  661. return $this->_attributes['namingStrategy'];
  662. }
  663. /**
  664. * Sets quote strategy.
  665. *
  666. * @since 2.3
  667. *
  668. * @param \Doctrine\ORM\Mapping\QuoteStrategy $quoteStrategy
  669. *
  670. * @return void
  671. */
  672. public function setQuoteStrategy(QuoteStrategy $quoteStrategy)
  673. {
  674. $this->_attributes['quoteStrategy'] = $quoteStrategy;
  675. }
  676. /**
  677. * Gets quote strategy.
  678. *
  679. * @since 2.3
  680. *
  681. * @return \Doctrine\ORM\Mapping\QuoteStrategy
  682. */
  683. public function getQuoteStrategy()
  684. {
  685. if ( ! isset($this->_attributes['quoteStrategy'])) {
  686. $this->_attributes['quoteStrategy'] = new DefaultQuoteStrategy();
  687. }
  688. return $this->_attributes['quoteStrategy'];
  689. }
  690. /**
  691. * Set the entity listener resolver.
  692. *
  693. * @since 2.4
  694. * @param \Doctrine\ORM\Mapping\EntityListenerResolver $resolver
  695. */
  696. public function setEntityListenerResolver(EntityListenerResolver $resolver)
  697. {
  698. $this->_attributes['entityListenerResolver'] = $resolver;
  699. }
  700. /**
  701. * Get the entity listener resolver.
  702. *
  703. * @since 2.4
  704. * @return \Doctrine\ORM\Mapping\EntityListenerResolver
  705. */
  706. public function getEntityListenerResolver()
  707. {
  708. if ( ! isset($this->_attributes['entityListenerResolver'])) {
  709. $this->_attributes['entityListenerResolver'] = new DefaultEntityListenerResolver();
  710. }
  711. return $this->_attributes['entityListenerResolver'];
  712. }
  713. /**
  714. * Set the entity repository factory.
  715. *
  716. * @since 2.4
  717. * @param \Doctrine\ORM\Repository\RepositoryFactory $repositoryFactory
  718. */
  719. public function setRepositoryFactory(RepositoryFactory $repositoryFactory)
  720. {
  721. $this->_attributes['repositoryFactory'] = $repositoryFactory;
  722. }
  723. /**
  724. * Get the entity repository factory.
  725. *
  726. * @since 2.4
  727. * @return \Doctrine\ORM\Repository\RepositoryFactory
  728. */
  729. public function getRepositoryFactory()
  730. {
  731. return isset($this->_attributes['repositoryFactory'])
  732. ? $this->_attributes['repositoryFactory']
  733. : new DefaultRepositoryFactory();
  734. }
  735. }