|
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\ORM; |
|
21
|
|
|
|
|
22
|
|
|
use Doctrine\Common\Annotations\AnnotationReader; |
|
23
|
|
|
use Doctrine\Common\Annotations\AnnotationRegistry; |
|
24
|
|
|
use Doctrine\Common\Annotations\CachedReader; |
|
25
|
|
|
use Doctrine\Common\Annotations\SimpleAnnotationReader; |
|
26
|
|
|
use Doctrine\Common\Cache\ArrayCache; |
|
27
|
|
|
use Doctrine\Common\Cache\Cache as CacheDriver; |
|
28
|
|
|
use Doctrine\Common\Proxy\AbstractProxyFactory; |
|
29
|
|
|
use Doctrine\ORM\Cache\CacheConfiguration; |
|
30
|
|
|
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver; |
|
31
|
|
|
use Doctrine\ORM\Mapping\DefaultEntityListenerResolver; |
|
32
|
|
|
use Doctrine\ORM\Mapping\DefaultNamingStrategy; |
|
33
|
|
|
use Doctrine\ORM\Mapping\DefaultQuoteStrategy; |
|
34
|
|
|
use Doctrine\ORM\Mapping\Driver\AnnotationDriver; |
|
35
|
|
|
use Doctrine\ORM\Mapping\EntityListenerResolver; |
|
36
|
|
|
use Doctrine\ORM\Mapping\NamingStrategy; |
|
37
|
|
|
use Doctrine\ORM\Mapping\QuoteStrategy; |
|
38
|
|
|
use Doctrine\ORM\Repository\DefaultRepositoryFactory; |
|
39
|
|
|
use Doctrine\ORM\Repository\RepositoryFactory; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Configuration container for all configuration options of Doctrine. |
|
43
|
|
|
* It combines all configuration options from DBAL & ORM. |
|
44
|
|
|
* |
|
45
|
|
|
* Internal note: When adding a new configuration option just write a getter/setter pair. |
|
46
|
|
|
* |
|
47
|
|
|
* @since 2.0 |
|
48
|
|
|
* @author Benjamin Eberlei <[email protected]> |
|
49
|
|
|
* @author Guilherme Blanco <[email protected]> |
|
50
|
|
|
* @author Jonathan Wage <[email protected]> |
|
51
|
|
|
* @author Roman Borschel <[email protected]> |
|
52
|
|
|
*/ |
|
53
|
|
|
class Configuration extends \Doctrine\DBAL\Configuration |
|
54
|
|
|
{ |
|
55
|
|
|
/** |
|
56
|
|
|
* Sets the directory where Doctrine generates any necessary proxy class files. |
|
57
|
|
|
* |
|
58
|
|
|
* @param string $dir |
|
59
|
|
|
* |
|
60
|
|
|
* @return void |
|
61
|
|
|
*/ |
|
62
|
2354 |
|
public function setProxyDir($dir) |
|
63
|
|
|
{ |
|
64
|
2354 |
|
$this->_attributes['proxyDir'] = $dir; |
|
65
|
2354 |
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Gets the directory where Doctrine generates any necessary proxy class files. |
|
69
|
|
|
* |
|
70
|
|
|
* @return string|null |
|
71
|
|
|
*/ |
|
72
|
2350 |
|
public function getProxyDir() |
|
73
|
|
|
{ |
|
74
|
2350 |
|
return isset($this->_attributes['proxyDir']) |
|
75
|
2350 |
|
? $this->_attributes['proxyDir'] |
|
76
|
2350 |
|
: null; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Gets the strategy for automatically generating proxy classes. |
|
81
|
|
|
* |
|
82
|
|
|
* @return int Possible values are constants of Doctrine\Common\Proxy\AbstractProxyFactory. |
|
83
|
|
|
*/ |
|
84
|
2352 |
|
public function getAutoGenerateProxyClasses() |
|
85
|
|
|
{ |
|
86
|
2352 |
|
return isset($this->_attributes['autoGenerateProxyClasses']) |
|
87
|
5 |
|
? $this->_attributes['autoGenerateProxyClasses'] |
|
88
|
2352 |
|
: AbstractProxyFactory::AUTOGENERATE_ALWAYS; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Sets the strategy for automatically generating proxy classes. |
|
93
|
|
|
* |
|
94
|
|
|
* @param boolean|int $autoGenerate Possible values are constants of Doctrine\Common\Proxy\AbstractProxyFactory. |
|
95
|
|
|
* True is converted to AUTOGENERATE_ALWAYS, false to AUTOGENERATE_NEVER. |
|
96
|
|
|
* |
|
97
|
|
|
* @return void |
|
98
|
|
|
*/ |
|
99
|
15 |
|
public function setAutoGenerateProxyClasses($autoGenerate) |
|
100
|
|
|
{ |
|
101
|
15 |
|
$this->_attributes['autoGenerateProxyClasses'] = (int) $autoGenerate; |
|
102
|
15 |
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* Gets the namespace where proxy classes reside. |
|
106
|
|
|
* |
|
107
|
|
|
* @return string|null |
|
108
|
|
|
*/ |
|
109
|
2349 |
|
public function getProxyNamespace() |
|
110
|
|
|
{ |
|
111
|
2349 |
|
return isset($this->_attributes['proxyNamespace']) |
|
112
|
2349 |
|
? $this->_attributes['proxyNamespace'] |
|
113
|
2349 |
|
: null; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Sets the namespace where proxy classes reside. |
|
118
|
|
|
* |
|
119
|
|
|
* @param string $ns |
|
120
|
|
|
* |
|
121
|
|
|
* @return void |
|
122
|
|
|
*/ |
|
123
|
2354 |
|
public function setProxyNamespace($ns) |
|
124
|
|
|
{ |
|
125
|
2354 |
|
$this->_attributes['proxyNamespace'] = $ns; |
|
126
|
2354 |
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Returns the umask that controls file permissions for generated proxies. |
|
130
|
|
|
* |
|
131
|
|
|
* @return int |
|
132
|
|
|
*/ |
|
133
|
2348 |
|
public function getProxyUmask() |
|
134
|
|
|
{ |
|
135
|
2348 |
|
return isset($this->_attributes['proxyUmask']) ? |
|
136
|
2348 |
|
$this->_attributes['proxyUmask'] : 0002; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @since 2.5.6 |
|
141
|
|
|
* |
|
142
|
|
|
* @param int $umask The umask that controls file permissions for generated proxies. |
|
143
|
|
|
* |
|
144
|
|
|
* @throws ORMException |
|
145
|
|
|
*/ |
|
146
|
1 |
|
public function setProxyUmask($umask) |
|
147
|
|
|
{ |
|
148
|
1 |
|
if ( ! is_int($umask)) { |
|
149
|
1 |
|
throw ORMException::invalidProxyUmask($umask); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
1 |
|
$this->_attributes['proxyUmask'] = $umask; |
|
153
|
1 |
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Sets the cache driver implementation that is used for metadata caching. |
|
157
|
|
|
* |
|
158
|
|
|
* @param MappingDriver $driverImpl |
|
159
|
|
|
* |
|
160
|
|
|
* @return void |
|
161
|
|
|
* |
|
162
|
|
|
* @todo Force parameter to be a Closure to ensure lazy evaluation |
|
163
|
|
|
* (as soon as a metadata cache is in effect, the driver never needs to initialize). |
|
164
|
|
|
*/ |
|
165
|
2353 |
|
public function setMetadataDriverImpl(MappingDriver $driverImpl) |
|
166
|
|
|
{ |
|
167
|
2353 |
|
$this->_attributes['metadataDriverImpl'] = $driverImpl; |
|
168
|
2353 |
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* Adds a new default annotation driver with a correctly configured annotation reader. If $useSimpleAnnotationReader |
|
172
|
|
|
* is true, the notation `@Entity` will work, otherwise, the notation `@ORM\Entity` will be supported. |
|
173
|
|
|
* |
|
174
|
|
|
* @param array $paths |
|
175
|
|
|
* @param bool $useSimpleAnnotationReader |
|
176
|
|
|
* |
|
177
|
|
|
* @return AnnotationDriver |
|
178
|
|
|
*/ |
|
179
|
2329 |
|
public function newDefaultAnnotationDriver($paths = array(), $useSimpleAnnotationReader = true) |
|
180
|
|
|
{ |
|
181
|
2329 |
|
AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php'); |
|
182
|
|
|
|
|
183
|
2329 |
|
if ($useSimpleAnnotationReader) { |
|
184
|
|
|
// Register the ORM Annotations in the AnnotationRegistry |
|
185
|
2329 |
|
$reader = new SimpleAnnotationReader(); |
|
186
|
2329 |
|
$reader->addNamespace('Doctrine\ORM\Mapping'); |
|
187
|
2329 |
|
$cachedReader = new CachedReader($reader, new ArrayCache()); |
|
188
|
|
|
|
|
189
|
2329 |
|
return new AnnotationDriver($cachedReader, (array) $paths); |
|
|
|
|
|
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
1 |
|
return new AnnotationDriver( |
|
193
|
1 |
|
new CachedReader(new AnnotationReader(), new ArrayCache()), |
|
|
|
|
|
|
194
|
1 |
|
(array) $paths |
|
195
|
|
|
); |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
/** |
|
199
|
|
|
* Adds a namespace under a certain alias. |
|
200
|
|
|
* |
|
201
|
|
|
* @param string $alias |
|
202
|
|
|
* @param string $namespace |
|
203
|
|
|
* |
|
204
|
|
|
* @return void |
|
205
|
|
|
*/ |
|
206
|
8 |
|
public function addEntityNamespace($alias, $namespace) |
|
207
|
|
|
{ |
|
208
|
8 |
|
$this->_attributes['entityNamespaces'][$alias] = $namespace; |
|
209
|
8 |
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* Resolves a registered namespace alias to the full namespace. |
|
213
|
|
|
* |
|
214
|
|
|
* @param string $entityNamespaceAlias |
|
215
|
|
|
* |
|
216
|
|
|
* @return string |
|
217
|
|
|
* |
|
218
|
|
|
* @throws ORMException |
|
219
|
|
|
*/ |
|
220
|
13 |
|
public function getEntityNamespace($entityNamespaceAlias) |
|
221
|
|
|
{ |
|
222
|
13 |
|
if ( ! isset($this->_attributes['entityNamespaces'][$entityNamespaceAlias])) { |
|
223
|
1 |
|
throw ORMException::unknownEntityNamespace($entityNamespaceAlias); |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
13 |
|
return trim($this->_attributes['entityNamespaces'][$entityNamespaceAlias], '\\'); |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
/** |
|
230
|
|
|
* Sets the entity alias map. |
|
231
|
|
|
* |
|
232
|
|
|
* @param array $entityNamespaces |
|
233
|
|
|
* |
|
234
|
|
|
* @return void |
|
235
|
|
|
*/ |
|
236
|
95 |
|
public function setEntityNamespaces(array $entityNamespaces) |
|
237
|
|
|
{ |
|
238
|
95 |
|
$this->_attributes['entityNamespaces'] = $entityNamespaces; |
|
239
|
95 |
|
} |
|
240
|
|
|
|
|
241
|
|
|
/** |
|
242
|
|
|
* Retrieves the list of registered entity namespace aliases. |
|
243
|
|
|
* |
|
244
|
|
|
* @return array |
|
245
|
|
|
*/ |
|
246
|
1 |
|
public function getEntityNamespaces() |
|
247
|
|
|
{ |
|
248
|
1 |
|
return $this->_attributes['entityNamespaces']; |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
/** |
|
252
|
|
|
* Gets the cache driver implementation that is used for the mapping metadata. |
|
253
|
|
|
* |
|
254
|
|
|
* @return MappingDriver|null |
|
255
|
|
|
* |
|
256
|
|
|
* @throws ORMException |
|
257
|
|
|
*/ |
|
258
|
1489 |
|
public function getMetadataDriverImpl() |
|
259
|
|
|
{ |
|
260
|
1489 |
|
return isset($this->_attributes['metadataDriverImpl']) |
|
261
|
1489 |
|
? $this->_attributes['metadataDriverImpl'] |
|
262
|
1489 |
|
: null; |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
/** |
|
266
|
|
|
* Gets the cache driver implementation that is used for the query cache (SQL cache). |
|
267
|
|
|
* |
|
268
|
|
|
* @return \Doctrine\Common\Cache\Cache|null |
|
269
|
|
|
*/ |
|
270
|
569 |
|
public function getQueryCacheImpl() |
|
271
|
|
|
{ |
|
272
|
569 |
|
return isset($this->_attributes['queryCacheImpl']) |
|
273
|
568 |
|
? $this->_attributes['queryCacheImpl'] |
|
274
|
569 |
|
: null; |
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
/** |
|
278
|
|
|
* Sets the cache driver implementation that is used for the query cache (SQL cache). |
|
279
|
|
|
* |
|
280
|
|
|
* @param \Doctrine\Common\Cache\Cache $cacheImpl |
|
281
|
|
|
* |
|
282
|
|
|
* @return void |
|
283
|
|
|
*/ |
|
284
|
2295 |
|
public function setQueryCacheImpl(CacheDriver $cacheImpl) |
|
285
|
|
|
{ |
|
286
|
2295 |
|
$this->_attributes['queryCacheImpl'] = $cacheImpl; |
|
287
|
2295 |
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* Gets the cache driver implementation that is used for the hydration cache (SQL cache). |
|
291
|
|
|
* |
|
292
|
|
|
* @return \Doctrine\Common\Cache\Cache|null |
|
293
|
|
|
*/ |
|
294
|
1 |
|
public function getHydrationCacheImpl() |
|
295
|
|
|
{ |
|
296
|
1 |
|
return isset($this->_attributes['hydrationCacheImpl']) |
|
297
|
1 |
|
? $this->_attributes['hydrationCacheImpl'] |
|
298
|
1 |
|
: null; |
|
299
|
|
|
} |
|
300
|
|
|
|
|
301
|
|
|
/** |
|
302
|
|
|
* Sets the cache driver implementation that is used for the hydration cache (SQL cache). |
|
303
|
|
|
* |
|
304
|
|
|
* @param \Doctrine\Common\Cache\Cache $cacheImpl |
|
305
|
|
|
* |
|
306
|
|
|
* @return void |
|
307
|
|
|
*/ |
|
308
|
1 |
|
public function setHydrationCacheImpl(CacheDriver $cacheImpl) |
|
309
|
|
|
{ |
|
310
|
1 |
|
$this->_attributes['hydrationCacheImpl'] = $cacheImpl; |
|
311
|
1 |
|
} |
|
312
|
|
|
|
|
313
|
|
|
/** |
|
314
|
|
|
* Gets the cache driver implementation that is used for metadata caching. |
|
315
|
|
|
* |
|
316
|
|
|
* @return \Doctrine\Common\Cache\Cache|null |
|
317
|
|
|
*/ |
|
318
|
2356 |
|
public function getMetadataCacheImpl() |
|
319
|
|
|
{ |
|
320
|
2356 |
|
return isset($this->_attributes['metadataCacheImpl']) |
|
321
|
2289 |
|
? $this->_attributes['metadataCacheImpl'] |
|
322
|
2356 |
|
: null; |
|
323
|
|
|
} |
|
324
|
|
|
|
|
325
|
|
|
/** |
|
326
|
|
|
* Sets the cache driver implementation that is used for metadata caching. |
|
327
|
|
|
* |
|
328
|
|
|
* @param \Doctrine\Common\Cache\Cache $cacheImpl |
|
329
|
|
|
* |
|
330
|
|
|
* @return void |
|
331
|
|
|
*/ |
|
332
|
2295 |
|
public function setMetadataCacheImpl(CacheDriver $cacheImpl) |
|
333
|
|
|
{ |
|
334
|
2295 |
|
$this->_attributes['metadataCacheImpl'] = $cacheImpl; |
|
335
|
2295 |
|
} |
|
336
|
|
|
|
|
337
|
|
|
/** |
|
338
|
|
|
* Adds a named DQL query to the configuration. |
|
339
|
|
|
* |
|
340
|
|
|
* @param string $name The name of the query. |
|
341
|
|
|
* @param string $dql The DQL query string. |
|
342
|
|
|
* |
|
343
|
|
|
* @return void |
|
344
|
|
|
*/ |
|
345
|
1 |
|
public function addNamedQuery($name, $dql) |
|
346
|
|
|
{ |
|
347
|
1 |
|
$this->_attributes['namedQueries'][$name] = $dql; |
|
348
|
1 |
|
} |
|
349
|
|
|
|
|
350
|
|
|
/** |
|
351
|
|
|
* Gets a previously registered named DQL query. |
|
352
|
|
|
* |
|
353
|
|
|
* @param string $name The name of the query. |
|
354
|
|
|
* |
|
355
|
|
|
* @return string The DQL query. |
|
356
|
|
|
* |
|
357
|
|
|
* @throws ORMException |
|
358
|
|
|
*/ |
|
359
|
2 |
|
public function getNamedQuery($name) |
|
360
|
|
|
{ |
|
361
|
2 |
|
if ( ! isset($this->_attributes['namedQueries'][$name])) { |
|
362
|
2 |
|
throw ORMException::namedQueryNotFound($name); |
|
363
|
|
|
} |
|
364
|
|
|
|
|
365
|
1 |
|
return $this->_attributes['namedQueries'][$name]; |
|
366
|
|
|
} |
|
367
|
|
|
|
|
368
|
|
|
/** |
|
369
|
|
|
* Adds a named native query to the configuration. |
|
370
|
|
|
* |
|
371
|
|
|
* @param string $name The name of the query. |
|
372
|
|
|
* @param string $sql The native SQL query string. |
|
373
|
|
|
* @param Query\ResultSetMapping $rsm The ResultSetMapping used for the results of the SQL query. |
|
374
|
|
|
* |
|
375
|
|
|
* @return void |
|
376
|
|
|
*/ |
|
377
|
1 |
|
public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm) |
|
378
|
|
|
{ |
|
379
|
1 |
|
$this->_attributes['namedNativeQueries'][$name] = array($sql, $rsm); |
|
380
|
1 |
|
} |
|
381
|
|
|
|
|
382
|
|
|
/** |
|
383
|
|
|
* Gets the components of a previously registered named native query. |
|
384
|
|
|
* |
|
385
|
|
|
* @param string $name The name of the query. |
|
386
|
|
|
* |
|
387
|
|
|
* @return array A tuple with the first element being the SQL string and the second |
|
388
|
|
|
* element being the ResultSetMapping. |
|
389
|
|
|
* |
|
390
|
|
|
* @throws ORMException |
|
391
|
|
|
*/ |
|
392
|
1 |
|
public function getNamedNativeQuery($name) |
|
393
|
|
|
{ |
|
394
|
1 |
|
if ( ! isset($this->_attributes['namedNativeQueries'][$name])) { |
|
395
|
|
|
throw ORMException::namedNativeQueryNotFound($name); |
|
396
|
|
|
} |
|
397
|
|
|
|
|
398
|
1 |
|
return $this->_attributes['namedNativeQueries'][$name]; |
|
399
|
|
|
} |
|
400
|
|
|
|
|
401
|
|
|
/** |
|
402
|
|
|
* Ensures that this Configuration instance contains settings that are |
|
403
|
|
|
* suitable for a production environment. |
|
404
|
|
|
* |
|
405
|
|
|
* @return void |
|
406
|
|
|
* |
|
407
|
|
|
* @throws ORMException If a configuration setting has a value that is not |
|
408
|
|
|
* suitable for a production environment. |
|
409
|
|
|
*/ |
|
410
|
8 |
|
public function ensureProductionSettings() |
|
411
|
|
|
{ |
|
412
|
8 |
|
$queryCacheImpl = $this->getQueryCacheImpl(); |
|
413
|
|
|
|
|
414
|
8 |
|
if ( ! $queryCacheImpl) { |
|
415
|
1 |
|
throw ORMException::queryCacheNotConfigured(); |
|
416
|
|
|
} |
|
417
|
|
|
|
|
418
|
7 |
|
if ($queryCacheImpl instanceof ArrayCache) { |
|
419
|
1 |
|
throw ORMException::queryCacheUsesNonPersistentCache($queryCacheImpl); |
|
420
|
|
|
} |
|
421
|
|
|
|
|
422
|
6 |
|
$metadataCacheImpl = $this->getMetadataCacheImpl(); |
|
423
|
|
|
|
|
424
|
6 |
|
if ( ! $metadataCacheImpl) { |
|
425
|
1 |
|
throw ORMException::metadataCacheNotConfigured(); |
|
426
|
|
|
} |
|
427
|
|
|
|
|
428
|
5 |
|
if ($metadataCacheImpl instanceof ArrayCache) { |
|
429
|
1 |
|
throw ORMException::metadataCacheUsesNonPersistentCache($metadataCacheImpl); |
|
430
|
|
|
} |
|
431
|
|
|
|
|
432
|
4 |
|
if ($this->getAutoGenerateProxyClasses()) { |
|
433
|
3 |
|
throw ORMException::proxyClassesAlwaysRegenerating(); |
|
434
|
|
|
} |
|
435
|
1 |
|
} |
|
436
|
|
|
|
|
437
|
|
|
/** |
|
438
|
|
|
* Registers a custom DQL function that produces a string value. |
|
439
|
|
|
* Such a function can then be used in any DQL statement in any place where string |
|
440
|
|
|
* functions are allowed. |
|
441
|
|
|
* |
|
442
|
|
|
* DQL function names are case-insensitive. |
|
443
|
|
|
* |
|
444
|
|
|
* @param string $name Function name. |
|
445
|
|
|
* @param string|callable $className Class name or a callable that returns the function. |
|
446
|
|
|
* |
|
447
|
|
|
* @return void |
|
448
|
|
|
* |
|
449
|
|
|
* @throws ORMException |
|
450
|
|
|
*/ |
|
451
|
3 |
|
public function addCustomStringFunction($name, $className) |
|
452
|
|
|
{ |
|
453
|
3 |
|
if (Query\Parser::isInternalFunction($name)) { |
|
454
|
1 |
|
throw ORMException::overwriteInternalDQLFunctionNotAllowed($name); |
|
455
|
|
|
} |
|
456
|
|
|
|
|
457
|
3 |
|
$this->_attributes['customStringFunctions'][strtolower($name)] = $className; |
|
458
|
3 |
|
} |
|
459
|
|
|
|
|
460
|
|
|
/** |
|
461
|
|
|
* Gets the implementation class name of a registered custom string DQL function. |
|
462
|
|
|
* |
|
463
|
|
|
* @param string $name |
|
464
|
|
|
* |
|
465
|
|
|
* @return string|null |
|
466
|
|
|
*/ |
|
467
|
4 |
|
public function getCustomStringFunction($name) |
|
468
|
|
|
{ |
|
469
|
4 |
|
$name = strtolower($name); |
|
470
|
|
|
|
|
471
|
4 |
|
return isset($this->_attributes['customStringFunctions'][$name]) |
|
472
|
3 |
|
? $this->_attributes['customStringFunctions'][$name] |
|
473
|
4 |
|
: null; |
|
474
|
|
|
} |
|
475
|
|
|
|
|
476
|
|
|
/** |
|
477
|
|
|
* Sets a map of custom DQL string functions. |
|
478
|
|
|
* |
|
479
|
|
|
* Keys must be function names and values the FQCN of the implementing class. |
|
480
|
|
|
* The function names will be case-insensitive in DQL. |
|
481
|
|
|
* |
|
482
|
|
|
* Any previously added string functions are discarded. |
|
483
|
|
|
* |
|
484
|
|
|
* @param array $functions The map of custom DQL string functions. |
|
485
|
|
|
* |
|
486
|
|
|
* @return void |
|
487
|
|
|
*/ |
|
488
|
1 |
|
public function setCustomStringFunctions(array $functions) |
|
489
|
|
|
{ |
|
490
|
1 |
|
foreach ($functions as $name => $className) { |
|
491
|
1 |
|
$this->addCustomStringFunction($name, $className); |
|
492
|
|
|
} |
|
493
|
1 |
|
} |
|
494
|
|
|
|
|
495
|
|
|
/** |
|
496
|
|
|
* Registers a custom DQL function that produces a numeric value. |
|
497
|
|
|
* Such a function can then be used in any DQL statement in any place where numeric |
|
498
|
|
|
* functions are allowed. |
|
499
|
|
|
* |
|
500
|
|
|
* DQL function names are case-insensitive. |
|
501
|
|
|
* |
|
502
|
|
|
* @param string $name Function name. |
|
503
|
|
|
* @param string|callable $className Class name or a callable that returns the function. |
|
504
|
|
|
* |
|
505
|
|
|
* @return void |
|
506
|
|
|
* |
|
507
|
|
|
* @throws ORMException |
|
508
|
|
|
*/ |
|
509
|
3 |
|
public function addCustomNumericFunction($name, $className) |
|
510
|
|
|
{ |
|
511
|
3 |
|
if (Query\Parser::isInternalFunction($name)) { |
|
512
|
1 |
|
throw ORMException::overwriteInternalDQLFunctionNotAllowed($name); |
|
513
|
|
|
} |
|
514
|
|
|
|
|
515
|
3 |
|
$this->_attributes['customNumericFunctions'][strtolower($name)] = $className; |
|
516
|
3 |
|
} |
|
517
|
|
|
|
|
518
|
|
|
/** |
|
519
|
|
|
* Gets the implementation class name of a registered custom numeric DQL function. |
|
520
|
|
|
* |
|
521
|
|
|
* @param string $name |
|
522
|
|
|
* |
|
523
|
|
|
* @return string|null |
|
524
|
|
|
*/ |
|
525
|
3 |
|
public function getCustomNumericFunction($name) |
|
526
|
|
|
{ |
|
527
|
3 |
|
$name = strtolower($name); |
|
528
|
|
|
|
|
529
|
3 |
|
return isset($this->_attributes['customNumericFunctions'][$name]) |
|
530
|
3 |
|
? $this->_attributes['customNumericFunctions'][$name] |
|
531
|
3 |
|
: null; |
|
532
|
|
|
} |
|
533
|
|
|
|
|
534
|
|
|
/** |
|
535
|
|
|
* Sets a map of custom DQL numeric functions. |
|
536
|
|
|
* |
|
537
|
|
|
* Keys must be function names and values the FQCN of the implementing class. |
|
538
|
|
|
* The function names will be case-insensitive in DQL. |
|
539
|
|
|
* |
|
540
|
|
|
* Any previously added numeric functions are discarded. |
|
541
|
|
|
* |
|
542
|
|
|
* @param array $functions The map of custom DQL numeric functions. |
|
543
|
|
|
* |
|
544
|
|
|
* @return void |
|
545
|
|
|
*/ |
|
546
|
2 |
|
public function setCustomNumericFunctions(array $functions) |
|
547
|
|
|
{ |
|
548
|
2 |
|
foreach ($functions as $name => $className) { |
|
549
|
1 |
|
$this->addCustomNumericFunction($name, $className); |
|
550
|
|
|
} |
|
551
|
2 |
|
} |
|
552
|
|
|
|
|
553
|
|
|
/** |
|
554
|
|
|
* Registers a custom DQL function that produces a date/time value. |
|
555
|
|
|
* Such a function can then be used in any DQL statement in any place where date/time |
|
556
|
|
|
* functions are allowed. |
|
557
|
|
|
* |
|
558
|
|
|
* DQL function names are case-insensitive. |
|
559
|
|
|
* |
|
560
|
|
|
* @param string $name Function name. |
|
561
|
|
|
* @param string|callable $className Class name or a callable that returns the function. |
|
562
|
|
|
* |
|
563
|
|
|
* @return void |
|
564
|
|
|
* |
|
565
|
|
|
* @throws ORMException |
|
566
|
|
|
*/ |
|
567
|
1 |
|
public function addCustomDatetimeFunction($name, $className) |
|
568
|
|
|
{ |
|
569
|
1 |
|
if (Query\Parser::isInternalFunction($name)) { |
|
570
|
1 |
|
throw ORMException::overwriteInternalDQLFunctionNotAllowed($name); |
|
571
|
|
|
} |
|
572
|
|
|
|
|
573
|
1 |
|
$this->_attributes['customDatetimeFunctions'][strtolower($name)] = $className; |
|
574
|
1 |
|
} |
|
575
|
|
|
|
|
576
|
|
|
/** |
|
577
|
|
|
* Gets the implementation class name of a registered custom date/time DQL function. |
|
578
|
|
|
* |
|
579
|
|
|
* @param string $name |
|
580
|
|
|
* |
|
581
|
|
|
* @return string|null |
|
582
|
|
|
*/ |
|
583
|
1 |
|
public function getCustomDatetimeFunction($name) |
|
584
|
|
|
{ |
|
585
|
1 |
|
$name = strtolower($name); |
|
586
|
|
|
|
|
587
|
1 |
|
return isset($this->_attributes['customDatetimeFunctions'][$name]) |
|
588
|
1 |
|
? $this->_attributes['customDatetimeFunctions'][$name] |
|
589
|
1 |
|
: null; |
|
590
|
|
|
} |
|
591
|
|
|
|
|
592
|
|
|
/** |
|
593
|
|
|
* Sets a map of custom DQL date/time functions. |
|
594
|
|
|
* |
|
595
|
|
|
* Keys must be function names and values the FQCN of the implementing class. |
|
596
|
|
|
* The function names will be case-insensitive in DQL. |
|
597
|
|
|
* |
|
598
|
|
|
* Any previously added date/time functions are discarded. |
|
599
|
|
|
* |
|
600
|
|
|
* @param array $functions The map of custom DQL date/time functions. |
|
601
|
|
|
* |
|
602
|
|
|
* @return void |
|
603
|
|
|
*/ |
|
604
|
1 |
|
public function setCustomDatetimeFunctions(array $functions) |
|
605
|
|
|
{ |
|
606
|
1 |
|
foreach ($functions as $name => $className) { |
|
607
|
1 |
|
$this->addCustomDatetimeFunction($name, $className); |
|
608
|
|
|
} |
|
609
|
1 |
|
} |
|
610
|
|
|
|
|
611
|
|
|
/** |
|
612
|
|
|
* Sets the custom hydrator modes in one pass. |
|
613
|
|
|
* |
|
614
|
|
|
* @param array $modes An array of ($modeName => $hydrator). |
|
615
|
|
|
* |
|
616
|
|
|
* @return void |
|
617
|
|
|
*/ |
|
618
|
1 |
|
public function setCustomHydrationModes($modes) |
|
619
|
|
|
{ |
|
620
|
1 |
|
$this->_attributes['customHydrationModes'] = array(); |
|
621
|
|
|
|
|
622
|
1 |
|
foreach ($modes as $modeName => $hydrator) { |
|
623
|
1 |
|
$this->addCustomHydrationMode($modeName, $hydrator); |
|
624
|
|
|
} |
|
625
|
1 |
|
} |
|
626
|
|
|
|
|
627
|
|
|
/** |
|
628
|
|
|
* Gets the hydrator class for the given hydration mode name. |
|
629
|
|
|
* |
|
630
|
|
|
* @param string $modeName The hydration mode name. |
|
631
|
|
|
* |
|
632
|
|
|
* @return string|null The hydrator class name. |
|
633
|
|
|
*/ |
|
634
|
3 |
|
public function getCustomHydrationMode($modeName) |
|
635
|
|
|
{ |
|
636
|
3 |
|
return isset($this->_attributes['customHydrationModes'][$modeName]) |
|
637
|
3 |
|
? $this->_attributes['customHydrationModes'][$modeName] |
|
638
|
3 |
|
: null; |
|
639
|
|
|
} |
|
640
|
|
|
|
|
641
|
|
|
/** |
|
642
|
|
|
* Adds a custom hydration mode. |
|
643
|
|
|
* |
|
644
|
|
|
* @param string $modeName The hydration mode name. |
|
645
|
|
|
* @param string $hydrator The hydrator class name. |
|
646
|
|
|
* |
|
647
|
|
|
* @return void |
|
648
|
|
|
*/ |
|
649
|
3 |
|
public function addCustomHydrationMode($modeName, $hydrator) |
|
650
|
|
|
{ |
|
651
|
3 |
|
$this->_attributes['customHydrationModes'][$modeName] = $hydrator; |
|
652
|
3 |
|
} |
|
653
|
|
|
|
|
654
|
|
|
/** |
|
655
|
|
|
* Sets a class metadata factory. |
|
656
|
|
|
* |
|
657
|
|
|
* @param string $cmfName |
|
658
|
|
|
* |
|
659
|
|
|
* @return void |
|
660
|
|
|
*/ |
|
661
|
1 |
|
public function setClassMetadataFactoryName($cmfName) |
|
662
|
|
|
{ |
|
663
|
1 |
|
$this->_attributes['classMetadataFactoryName'] = $cmfName; |
|
664
|
1 |
|
} |
|
665
|
|
|
|
|
666
|
|
|
/** |
|
667
|
|
|
* @return string |
|
668
|
|
|
*/ |
|
669
|
2348 |
|
public function getClassMetadataFactoryName() |
|
670
|
|
|
{ |
|
671
|
2348 |
|
if ( ! isset($this->_attributes['classMetadataFactoryName'])) { |
|
672
|
2348 |
|
$this->_attributes['classMetadataFactoryName'] = 'Doctrine\ORM\Mapping\ClassMetadataFactory'; |
|
673
|
|
|
} |
|
674
|
|
|
|
|
675
|
2348 |
|
return $this->_attributes['classMetadataFactoryName']; |
|
676
|
|
|
} |
|
677
|
|
|
|
|
678
|
|
|
/** |
|
679
|
|
|
* Adds a filter to the list of possible filters. |
|
680
|
|
|
* |
|
681
|
|
|
* @param string $name The name of the filter. |
|
682
|
|
|
* @param string $className The class name of the filter. |
|
683
|
|
|
*/ |
|
684
|
46 |
|
public function addFilter($name, $className) |
|
685
|
|
|
{ |
|
686
|
46 |
|
$this->_attributes['filters'][$name] = $className; |
|
687
|
46 |
|
} |
|
688
|
|
|
|
|
689
|
|
|
/** |
|
690
|
|
|
* Gets the class name for a given filter name. |
|
691
|
|
|
* |
|
692
|
|
|
* @param string $name The name of the filter. |
|
693
|
|
|
* |
|
694
|
|
|
* @return string The class name of the filter, or null if it is not |
|
695
|
|
|
* defined. |
|
696
|
|
|
*/ |
|
697
|
45 |
|
public function getFilterClassName($name) |
|
698
|
|
|
{ |
|
699
|
45 |
|
return isset($this->_attributes['filters'][$name]) |
|
700
|
45 |
|
? $this->_attributes['filters'][$name] |
|
701
|
45 |
|
: null; |
|
702
|
|
|
} |
|
703
|
|
|
|
|
704
|
|
|
/** |
|
705
|
|
|
* Sets default repository class. |
|
706
|
|
|
* |
|
707
|
|
|
* @since 2.2 |
|
708
|
|
|
* |
|
709
|
|
|
* @param string $className |
|
710
|
|
|
* |
|
711
|
|
|
* @return void |
|
712
|
|
|
* |
|
713
|
|
|
* @throws ORMException If not is a \Doctrine\Common\Persistence\ObjectRepository |
|
714
|
|
|
*/ |
|
715
|
3 |
|
public function setDefaultRepositoryClassName($className) |
|
716
|
|
|
{ |
|
717
|
3 |
|
$reflectionClass = new \ReflectionClass($className); |
|
718
|
|
|
|
|
719
|
3 |
|
if ( ! $reflectionClass->implementsInterface('Doctrine\Common\Persistence\ObjectRepository')) { |
|
720
|
1 |
|
throw ORMException::invalidEntityRepository($className); |
|
721
|
|
|
} |
|
722
|
|
|
|
|
723
|
2 |
|
$this->_attributes['defaultRepositoryClassName'] = $className; |
|
724
|
2 |
|
} |
|
725
|
|
|
|
|
726
|
|
|
/** |
|
727
|
|
|
* Get default repository class. |
|
728
|
|
|
* |
|
729
|
|
|
* @since 2.2 |
|
730
|
|
|
* |
|
731
|
|
|
* @return string |
|
732
|
|
|
*/ |
|
733
|
142 |
|
public function getDefaultRepositoryClassName() |
|
734
|
|
|
{ |
|
735
|
142 |
|
return isset($this->_attributes['defaultRepositoryClassName']) |
|
736
|
2 |
|
? $this->_attributes['defaultRepositoryClassName'] |
|
737
|
142 |
|
: 'Doctrine\ORM\EntityRepository'; |
|
738
|
|
|
} |
|
739
|
|
|
|
|
740
|
|
|
/** |
|
741
|
|
|
* Sets naming strategy. |
|
742
|
|
|
* |
|
743
|
|
|
* @since 2.3 |
|
744
|
|
|
* |
|
745
|
|
|
* @param NamingStrategy $namingStrategy |
|
746
|
|
|
* |
|
747
|
|
|
* @return void |
|
748
|
|
|
*/ |
|
749
|
7 |
|
public function setNamingStrategy(NamingStrategy $namingStrategy) |
|
750
|
|
|
{ |
|
751
|
7 |
|
$this->_attributes['namingStrategy'] = $namingStrategy; |
|
752
|
7 |
|
} |
|
753
|
|
|
|
|
754
|
|
|
/** |
|
755
|
|
|
* Gets naming strategy.. |
|
756
|
|
|
* |
|
757
|
|
|
* @since 2.3 |
|
758
|
|
|
* |
|
759
|
|
|
* @return NamingStrategy |
|
760
|
|
|
*/ |
|
761
|
428 |
|
public function getNamingStrategy() |
|
762
|
|
|
{ |
|
763
|
428 |
|
if ( ! isset($this->_attributes['namingStrategy'])) { |
|
764
|
428 |
|
$this->_attributes['namingStrategy'] = new DefaultNamingStrategy(); |
|
765
|
|
|
} |
|
766
|
|
|
|
|
767
|
428 |
|
return $this->_attributes['namingStrategy']; |
|
768
|
|
|
} |
|
769
|
|
|
|
|
770
|
|
|
/** |
|
771
|
|
|
* Sets quote strategy. |
|
772
|
|
|
* |
|
773
|
|
|
* @since 2.3 |
|
774
|
|
|
* |
|
775
|
|
|
* @param \Doctrine\ORM\Mapping\QuoteStrategy $quoteStrategy |
|
776
|
|
|
* |
|
777
|
|
|
* @return void |
|
778
|
|
|
*/ |
|
779
|
2 |
|
public function setQuoteStrategy(QuoteStrategy $quoteStrategy) |
|
780
|
|
|
{ |
|
781
|
2 |
|
$this->_attributes['quoteStrategy'] = $quoteStrategy; |
|
782
|
2 |
|
} |
|
783
|
|
|
|
|
784
|
|
|
/** |
|
785
|
|
|
* Gets quote strategy. |
|
786
|
|
|
* |
|
787
|
|
|
* @since 2.3 |
|
788
|
|
|
* |
|
789
|
|
|
* @return \Doctrine\ORM\Mapping\QuoteStrategy |
|
790
|
|
|
*/ |
|
791
|
1615 |
|
public function getQuoteStrategy() |
|
792
|
|
|
{ |
|
793
|
1615 |
|
if ( ! isset($this->_attributes['quoteStrategy'])) { |
|
794
|
1615 |
|
$this->_attributes['quoteStrategy'] = new DefaultQuoteStrategy(); |
|
795
|
|
|
} |
|
796
|
|
|
|
|
797
|
1615 |
|
return $this->_attributes['quoteStrategy']; |
|
798
|
|
|
} |
|
799
|
|
|
|
|
800
|
|
|
/** |
|
801
|
|
|
* Set the entity listener resolver. |
|
802
|
|
|
* |
|
803
|
|
|
* @since 2.4 |
|
804
|
|
|
* @param \Doctrine\ORM\Mapping\EntityListenerResolver $resolver |
|
805
|
|
|
*/ |
|
806
|
1 |
|
public function setEntityListenerResolver(EntityListenerResolver $resolver) |
|
807
|
|
|
{ |
|
808
|
1 |
|
$this->_attributes['entityListenerResolver'] = $resolver; |
|
809
|
1 |
|
} |
|
810
|
|
|
|
|
811
|
|
|
/** |
|
812
|
|
|
* Get the entity listener resolver. |
|
813
|
|
|
* |
|
814
|
|
|
* @since 2.4 |
|
815
|
|
|
* @return \Doctrine\ORM\Mapping\EntityListenerResolver |
|
816
|
|
|
*/ |
|
817
|
2348 |
|
public function getEntityListenerResolver() |
|
818
|
|
|
{ |
|
819
|
2348 |
|
if ( ! isset($this->_attributes['entityListenerResolver'])) { |
|
820
|
2348 |
|
$this->_attributes['entityListenerResolver'] = new DefaultEntityListenerResolver(); |
|
821
|
|
|
} |
|
822
|
|
|
|
|
823
|
2348 |
|
return $this->_attributes['entityListenerResolver']; |
|
824
|
|
|
} |
|
825
|
|
|
|
|
826
|
|
|
/** |
|
827
|
|
|
* Set the entity repository factory. |
|
828
|
|
|
* |
|
829
|
|
|
* @since 2.4 |
|
830
|
|
|
* @param \Doctrine\ORM\Repository\RepositoryFactory $repositoryFactory |
|
831
|
|
|
*/ |
|
832
|
|
|
public function setRepositoryFactory(RepositoryFactory $repositoryFactory) |
|
833
|
|
|
{ |
|
834
|
|
|
$this->_attributes['repositoryFactory'] = $repositoryFactory; |
|
835
|
|
|
} |
|
836
|
|
|
|
|
837
|
|
|
/** |
|
838
|
|
|
* Get the entity repository factory. |
|
839
|
|
|
* |
|
840
|
|
|
* @since 2.4 |
|
841
|
|
|
* @return \Doctrine\ORM\Repository\RepositoryFactory |
|
842
|
|
|
*/ |
|
843
|
2347 |
|
public function getRepositoryFactory() |
|
844
|
|
|
{ |
|
845
|
2347 |
|
return isset($this->_attributes['repositoryFactory']) |
|
846
|
|
|
? $this->_attributes['repositoryFactory'] |
|
847
|
2347 |
|
: new DefaultRepositoryFactory(); |
|
848
|
|
|
} |
|
849
|
|
|
|
|
850
|
|
|
/** |
|
851
|
|
|
* @since 2.5 |
|
852
|
|
|
* |
|
853
|
|
|
* @return boolean |
|
854
|
|
|
*/ |
|
855
|
2348 |
|
public function isSecondLevelCacheEnabled() |
|
856
|
|
|
{ |
|
857
|
2348 |
|
return isset($this->_attributes['isSecondLevelCacheEnabled']) |
|
858
|
278 |
|
? $this->_attributes['isSecondLevelCacheEnabled'] |
|
859
|
2348 |
|
: false; |
|
860
|
|
|
} |
|
861
|
|
|
|
|
862
|
|
|
/** |
|
863
|
|
|
* @since 2.5 |
|
864
|
|
|
* |
|
865
|
|
|
* @param boolean $flag |
|
866
|
|
|
* |
|
867
|
|
|
* @return void |
|
868
|
|
|
*/ |
|
869
|
278 |
|
public function setSecondLevelCacheEnabled($flag = true) |
|
870
|
|
|
{ |
|
871
|
278 |
|
$this->_attributes['isSecondLevelCacheEnabled'] = (boolean) $flag; |
|
872
|
278 |
|
} |
|
873
|
|
|
|
|
874
|
|
|
/** |
|
875
|
|
|
* @since 2.5 |
|
876
|
|
|
* |
|
877
|
|
|
* @param \Doctrine\ORM\Cache\CacheConfiguration $cacheConfig |
|
878
|
|
|
* |
|
879
|
|
|
* @return void |
|
880
|
|
|
*/ |
|
881
|
279 |
|
public function setSecondLevelCacheConfiguration(CacheConfiguration $cacheConfig) |
|
882
|
|
|
{ |
|
883
|
279 |
|
$this->_attributes['secondLevelCacheConfiguration'] = $cacheConfig; |
|
884
|
279 |
|
} |
|
885
|
|
|
|
|
886
|
|
|
/** |
|
887
|
|
|
* @since 2.5 |
|
888
|
|
|
* |
|
889
|
|
|
* @return \Doctrine\ORM\Cache\CacheConfiguration|null |
|
890
|
|
|
*/ |
|
891
|
279 |
|
public function getSecondLevelCacheConfiguration() |
|
892
|
|
|
{ |
|
893
|
279 |
|
if ( ! isset($this->_attributes['secondLevelCacheConfiguration']) && $this->isSecondLevelCacheEnabled()) { |
|
894
|
|
|
$this->_attributes['secondLevelCacheConfiguration'] = new CacheConfiguration(); |
|
895
|
|
|
} |
|
896
|
|
|
|
|
897
|
279 |
|
return isset($this->_attributes['secondLevelCacheConfiguration']) |
|
898
|
279 |
|
? $this->_attributes['secondLevelCacheConfiguration'] |
|
899
|
279 |
|
: null; |
|
900
|
|
|
} |
|
901
|
|
|
|
|
902
|
|
|
/** |
|
903
|
|
|
* Returns query hints, which will be applied to every query in application |
|
904
|
|
|
* |
|
905
|
|
|
* @since 2.5 |
|
906
|
|
|
* |
|
907
|
|
|
* @return array |
|
908
|
|
|
*/ |
|
909
|
946 |
|
public function getDefaultQueryHints() |
|
910
|
|
|
{ |
|
911
|
946 |
|
return isset($this->_attributes['defaultQueryHints']) ? $this->_attributes['defaultQueryHints'] : array(); |
|
912
|
|
|
} |
|
913
|
|
|
|
|
914
|
|
|
/** |
|
915
|
|
|
* Sets array of query hints, which will be applied to every query in application |
|
916
|
|
|
* |
|
917
|
|
|
* @since 2.5 |
|
918
|
|
|
* |
|
919
|
|
|
* @param array $defaultQueryHints |
|
920
|
|
|
*/ |
|
921
|
1 |
|
public function setDefaultQueryHints(array $defaultQueryHints) |
|
922
|
|
|
{ |
|
923
|
1 |
|
$this->_attributes['defaultQueryHints'] = $defaultQueryHints; |
|
924
|
1 |
|
} |
|
925
|
|
|
|
|
926
|
|
|
/** |
|
927
|
|
|
* Gets the value of a default query hint. If the hint name is not recognized, FALSE is returned. |
|
928
|
|
|
* |
|
929
|
|
|
* @since 2.5 |
|
930
|
|
|
* |
|
931
|
|
|
* @param string $name The name of the hint. |
|
932
|
|
|
* |
|
933
|
|
|
* @return mixed The value of the hint or FALSE, if the hint name is not recognized. |
|
934
|
|
|
*/ |
|
935
|
|
|
public function getDefaultQueryHint($name) |
|
936
|
|
|
{ |
|
937
|
|
|
return isset($this->_attributes['defaultQueryHints'][$name]) |
|
938
|
|
|
? $this->_attributes['defaultQueryHints'][$name] |
|
939
|
|
|
: false; |
|
940
|
|
|
} |
|
941
|
|
|
|
|
942
|
|
|
/** |
|
943
|
|
|
* Sets a default query hint. If the hint name is not recognized, it is silently ignored. |
|
944
|
|
|
* |
|
945
|
|
|
* @since 2.5 |
|
946
|
|
|
* |
|
947
|
|
|
* @param string $name The name of the hint. |
|
948
|
|
|
* @param mixed $value The value of the hint. |
|
949
|
|
|
*/ |
|
950
|
1 |
|
public function setDefaultQueryHint($name, $value) |
|
951
|
|
|
{ |
|
952
|
1 |
|
$this->_attributes['defaultQueryHints'][$name] = $value; |
|
953
|
1 |
|
} |
|
954
|
|
|
} |
|
955
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: