/vendor/doctrine/doctrine-orm-module/src/DoctrineORMModule/Options/Configuration.php

https://bitbucket.org/zbahij/eprojets_app · PHP · 464 lines · 179 code · 67 blank · 218 comment · 3 complexity · 4b74114d6af9d1f305e27c1116cf1bee MD5 · raw file

  1. <?php
  2. namespace DoctrineORMModule\Options;
  3. use DoctrineORMModule\Options\DBALConfiguration;
  4. use Doctrine\ORM\Mapping\NamingStrategy;
  5. use Zend\Stdlib\Exception\InvalidArgumentException;
  6. /**
  7. * Configuration options for an ORM Configuration
  8. *
  9. * @license MIT
  10. * @link http://www.doctrine-project.org/
  11. * @author Kyle Spraggs <theman@spiffyjr.me>
  12. * @author Marco Pivetta <ocramius@gmail.com>
  13. */
  14. class Configuration extends DBALConfiguration
  15. {
  16. /**
  17. * Set the cache key for the metadata cache. Cache key
  18. * is assembled as "doctrine.cache.{key}" and pulled from
  19. * service locator.
  20. *
  21. * @var string
  22. */
  23. protected $metadataCache = 'array';
  24. /**
  25. * Set the cache key for the query cache. Cache key
  26. * is assembled as "doctrine.cache.{key}" and pulled from
  27. * service locator.
  28. *
  29. * @var string
  30. */
  31. protected $queryCache = 'array';
  32. /**
  33. * Set the cache key for the result cache. Cache key
  34. * is assembled as "doctrine.cache.{key}" and pulled from
  35. * service locator.
  36. *
  37. * @var string
  38. */
  39. protected $resultCache = 'array';
  40. /**
  41. * Set the driver key for the metadata driver. Driver key
  42. * is assembeled as "doctrine.driver.{key}" and pulled from
  43. * service locator.
  44. *
  45. * @var string
  46. */
  47. protected $driver = 'orm_default';
  48. /**
  49. * Automatic generation of proxies (disable for production!)
  50. *
  51. * @var bool
  52. */
  53. protected $generateProxies = true;
  54. /**
  55. * Proxy directory.
  56. *
  57. * @var string
  58. */
  59. protected $proxyDir = 'data';
  60. /**
  61. * Proxy namespace.
  62. *
  63. * @var string
  64. */
  65. protected $proxyNamespace = 'DoctrineORMModule\Proxy';
  66. /**
  67. * Entity alias map.
  68. *
  69. * @var array
  70. */
  71. protected $entityNamespaces = array();
  72. /**
  73. * Keys must be function names and values the FQCN of the implementing class.
  74. * The function names will be case-insensitive in DQL.
  75. *
  76. * @var array
  77. */
  78. protected $datetimeFunctions = array();
  79. /**
  80. * Keys must be function names and values the FQCN of the implementing class.
  81. * The function names will be case-insensitive in DQL.
  82. *
  83. * @var array
  84. */
  85. protected $stringFunctions = array();
  86. /**
  87. * Keys must be function names and values the FQCN of the implementing class.
  88. * The function names will be case-insensitive in DQL.
  89. *
  90. * @var array
  91. */
  92. protected $numericFunctions = array();
  93. /**
  94. * Keys must be the name of the custom filter and the value must be
  95. * the class name for the custom filter.
  96. *
  97. * @var array
  98. */
  99. protected $filters = array();
  100. /**
  101. * Keys must be the name of the query and values the DQL query string.
  102. *
  103. * @var array
  104. */
  105. protected $namedQueries = array();
  106. /**
  107. * Keys must be the name of the query and the value is an array containing
  108. * the keys 'sql' for native SQL query string and 'rsm' for the Query\ResultSetMapping.
  109. *
  110. * @var array
  111. */
  112. protected $namedNativeQueries = array();
  113. /**
  114. * Keys must be the name of the custom hydration method and the value must be
  115. * the class name for the custom hydrator
  116. *
  117. * @var array
  118. */
  119. protected $customHydrationModes = array();
  120. /**
  121. * Naming strategy or name of the naming strategy service to be set in ORM
  122. * configuration (if any)
  123. *
  124. * @var string|null|NamingStrategy
  125. */
  126. protected $namingStrategy;
  127. /**
  128. * @param array $datetimeFunctions
  129. * @return self
  130. */
  131. public function setDatetimeFunctions($datetimeFunctions)
  132. {
  133. $this->datetimeFunctions = $datetimeFunctions;
  134. return $this;
  135. }
  136. /**
  137. * @return array
  138. */
  139. public function getDatetimeFunctions()
  140. {
  141. return $this->datetimeFunctions;
  142. }
  143. /**
  144. * @param string $driver
  145. * @return self
  146. */
  147. public function setDriver($driver)
  148. {
  149. $this->driver = $driver;
  150. return $this;
  151. }
  152. /**
  153. * @return string
  154. */
  155. public function getDriver()
  156. {
  157. return "doctrine.driver.{$this->driver}";
  158. }
  159. /**
  160. * @param array $entityNamespaces
  161. * @return self
  162. */
  163. public function setEntityNamespaces($entityNamespaces)
  164. {
  165. $this->entityNamespaces = $entityNamespaces;
  166. return $this;
  167. }
  168. /**
  169. * @return array
  170. */
  171. public function getEntityNamespaces()
  172. {
  173. return $this->entityNamespaces;
  174. }
  175. /**
  176. * @param boolean $generateProxies
  177. * @return self
  178. */
  179. public function setGenerateProxies($generateProxies)
  180. {
  181. $this->generateProxies = $generateProxies;
  182. return $this;
  183. }
  184. /**
  185. * @return boolean
  186. */
  187. public function getGenerateProxies()
  188. {
  189. return $this->generateProxies;
  190. }
  191. /**
  192. * @param string $metadataCache
  193. * @return self
  194. */
  195. public function setMetadataCache($metadataCache)
  196. {
  197. $this->metadataCache = $metadataCache;
  198. return $this;
  199. }
  200. /**
  201. * @return string
  202. */
  203. public function getMetadataCache()
  204. {
  205. return "doctrine.cache.{$this->metadataCache}";
  206. }
  207. /**
  208. * @param string $resultCache
  209. * @return self
  210. */
  211. public function setResultCache($resultCache)
  212. {
  213. $this->resultCache = $resultCache;
  214. return $this;
  215. }
  216. /**
  217. * @return string
  218. */
  219. public function getResultCache()
  220. {
  221. return "doctrine.cache.{$this->resultCache}";
  222. }
  223. /**
  224. * @param array $namedNativeQueries
  225. * @return self
  226. */
  227. public function setNamedNativeQueries($namedNativeQueries)
  228. {
  229. $this->namedNativeQueries = $namedNativeQueries;
  230. return $this;
  231. }
  232. /**
  233. * @return array
  234. */
  235. public function getNamedNativeQueries()
  236. {
  237. return $this->namedNativeQueries;
  238. }
  239. /**
  240. * @param array $namedQueries
  241. * @return self
  242. */
  243. public function setNamedQueries($namedQueries)
  244. {
  245. $this->namedQueries = $namedQueries;
  246. return $this;
  247. }
  248. /**
  249. * @return array
  250. */
  251. public function getNamedQueries()
  252. {
  253. return $this->namedQueries;
  254. }
  255. /**
  256. * @param array $numericFunctions
  257. * @return self
  258. */
  259. public function setNumericFunctions($numericFunctions)
  260. {
  261. $this->numericFunctions = $numericFunctions;
  262. return $this;
  263. }
  264. /**
  265. * @return array
  266. */
  267. public function getNumericFunctions()
  268. {
  269. return $this->numericFunctions;
  270. }
  271. /**
  272. *
  273. * @param array $filters
  274. * @return self
  275. */
  276. public function setFilters($filters)
  277. {
  278. $this->filters = $filters;
  279. return $this;
  280. }
  281. /**
  282. *
  283. * @return array
  284. */
  285. public function getFilters()
  286. {
  287. return $this->filters;
  288. }
  289. /**
  290. * @param string $proxyDir
  291. * @return self
  292. */
  293. public function setProxyDir($proxyDir)
  294. {
  295. $this->proxyDir = $proxyDir;
  296. return $this;
  297. }
  298. /**
  299. * @return string
  300. */
  301. public function getProxyDir()
  302. {
  303. return $this->proxyDir;
  304. }
  305. /**
  306. * @param string $proxyNamespace
  307. * @return self
  308. */
  309. public function setProxyNamespace($proxyNamespace)
  310. {
  311. $this->proxyNamespace = $proxyNamespace;
  312. return $this;
  313. }
  314. /**
  315. * @return string
  316. */
  317. public function getProxyNamespace()
  318. {
  319. return $this->proxyNamespace;
  320. }
  321. /**
  322. * @param string $queryCache
  323. * @return self
  324. */
  325. public function setQueryCache($queryCache)
  326. {
  327. $this->queryCache = $queryCache;
  328. return $this;
  329. }
  330. /**
  331. * @return string
  332. */
  333. public function getQueryCache()
  334. {
  335. return "doctrine.cache.{$this->queryCache}";
  336. }
  337. /**
  338. * @param array $stringFunctions
  339. * @return self
  340. */
  341. public function setStringFunctions($stringFunctions)
  342. {
  343. $this->stringFunctions = $stringFunctions;
  344. return $this;
  345. }
  346. /**
  347. * @return array
  348. */
  349. public function getStringFunctions()
  350. {
  351. return $this->stringFunctions;
  352. }
  353. /**
  354. * @param array $modes
  355. * @return self
  356. */
  357. public function setCustomHydrationModes($modes)
  358. {
  359. $this->customHydrationModes = $modes;
  360. return $this;
  361. }
  362. /**
  363. * @return array
  364. */
  365. public function getCustomHydrationModes()
  366. {
  367. return $this->customHydrationModes;
  368. }
  369. /**
  370. * @param string|null|NamingStrategy $namingStrategy
  371. * @return self
  372. * @throws InvalidArgumentException when the provided naming strategy does not fit the expected type
  373. */
  374. public function setNamingStrategy($namingStrategy)
  375. {
  376. if (
  377. null === $namingStrategy
  378. || is_string($namingStrategy)
  379. || $namingStrategy instanceof NamingStrategy
  380. ) {
  381. $this->namingStrategy = $namingStrategy;
  382. return $this;
  383. }
  384. throw new InvalidArgumentException(sprintf(
  385. 'namingStrategy must be either a string, a Doctrine\ORM\Mapping\NamingStrategy '
  386. . 'instance or null, %s given',
  387. is_object($namingStrategy) ? get_class($namingStrategy) : gettype($namingStrategy)
  388. ));
  389. }
  390. /**
  391. * @return string|null|NamingStrategy
  392. */
  393. public function getNamingStrategy()
  394. {
  395. return $this->namingStrategy;
  396. }
  397. }