|
23 | 23 | use Doctrine\ORM\Exception\InvalidEntityRepository;
|
24 | 24 | use Doctrine\ORM\Exception\NamedNativeQueryNotFound;
|
25 | 25 | use Doctrine\ORM\Exception\NamedQueryNotFound;
|
26 |
| -use Doctrine\ORM\Exception\ORMException; |
27 | 26 | use Doctrine\ORM\Exception\ProxyClassesAlwaysRegenerating;
|
28 | 27 | use Doctrine\ORM\Exception\UnknownEntityNamespace;
|
29 | 28 | use Doctrine\ORM\Mapping\ClassMetadataFactory;
|
|
43 | 42 | use ReflectionClass;
|
44 | 43 |
|
45 | 44 | use function class_exists;
|
| 45 | +use function method_exists; |
46 | 46 | use function strtolower;
|
47 | 47 | use function trim;
|
48 | 48 |
|
@@ -251,46 +251,142 @@ public function getMetadataDriverImpl()
|
251 | 251 | return $this->_attributes['metadataDriverImpl'] ?? null;
|
252 | 252 | }
|
253 | 253 |
|
| 254 | + /** |
| 255 | + * Gets the cache driver implementation that is used for query result caching. |
| 256 | + */ |
| 257 | + public function getResultCache(): ?CacheItemPoolInterface |
| 258 | + { |
| 259 | + // Compatibility with DBAL < 3.2 |
| 260 | + if (! method_exists(parent::class, 'getResultCache')) { |
| 261 | + $cacheImpl = $this->getResultCacheImpl(); |
| 262 | + |
| 263 | + return $cacheImpl ? CacheAdapter::wrap($cacheImpl) : null; |
| 264 | + } |
| 265 | + |
| 266 | + return parent::getResultCache(); |
| 267 | + } |
| 268 | + |
| 269 | + /** |
| 270 | + * Sets the cache driver implementation that is used for query result caching. |
| 271 | + */ |
| 272 | + public function setResultCache(CacheItemPoolInterface $cache): void |
| 273 | + { |
| 274 | + // Compatibility with DBAL < 3.2 |
| 275 | + if (! method_exists(parent::class, 'setResultCache')) { |
| 276 | + $this->setResultCacheImpl(DoctrineProvider::wrap($cache)); |
| 277 | + |
| 278 | + return; |
| 279 | + } |
| 280 | + |
| 281 | + parent::setResultCache($cache); |
| 282 | + } |
| 283 | + |
254 | 284 | /**
|
255 | 285 | * Gets the cache driver implementation that is used for the query cache (SQL cache).
|
256 | 286 | *
|
| 287 | + * @deprecated Call {@see getQueryCache()} instead. |
| 288 | + * |
257 | 289 | * @return CacheDriver|null
|
258 | 290 | */
|
259 | 291 | public function getQueryCacheImpl()
|
260 | 292 | {
|
| 293 | + Deprecation::trigger( |
| 294 | + 'doctrine/orm', |
| 295 | + 'https://github.com/doctrine/orm/pull/9002', |
| 296 | + 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getQueryCache() instead.', |
| 297 | + __METHOD__ |
| 298 | + ); |
| 299 | + |
261 | 300 | return $this->_attributes['queryCacheImpl'] ?? null;
|
262 | 301 | }
|
263 | 302 |
|
264 | 303 | /**
|
265 | 304 | * Sets the cache driver implementation that is used for the query cache (SQL cache).
|
266 | 305 | *
|
| 306 | + * @deprecated Call {@see setQueryCache()} instead. |
| 307 | + * |
267 | 308 | * @return void
|
268 | 309 | */
|
269 | 310 | public function setQueryCacheImpl(CacheDriver $cacheImpl)
|
270 | 311 | {
|
| 312 | + Deprecation::trigger( |
| 313 | + 'doctrine/orm', |
| 314 | + 'https://github.com/doctrine/orm/pull/9002', |
| 315 | + 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use setQueryCache() instead.', |
| 316 | + __METHOD__ |
| 317 | + ); |
| 318 | + |
| 319 | + $this->_attributes['queryCache'] = CacheAdapter::wrap($cacheImpl); |
271 | 320 | $this->_attributes['queryCacheImpl'] = $cacheImpl;
|
272 | 321 | }
|
273 | 322 |
|
| 323 | + /** |
| 324 | + * Gets the cache driver implementation that is used for the query cache (SQL cache). |
| 325 | + */ |
| 326 | + public function getQueryCache(): ?CacheItemPoolInterface |
| 327 | + { |
| 328 | + return $this->_attributes['queryCache'] ?? null; |
| 329 | + } |
| 330 | + |
| 331 | + /** |
| 332 | + * Sets the cache driver implementation that is used for the query cache (SQL cache). |
| 333 | + */ |
| 334 | + public function setQueryCache(CacheItemPoolInterface $cache): void |
| 335 | + { |
| 336 | + $this->_attributes['queryCache'] = $cache; |
| 337 | + $this->_attributes['queryCacheImpl'] = DoctrineProvider::wrap($cache); |
| 338 | + } |
| 339 | + |
274 | 340 | /**
|
275 | 341 | * Gets the cache driver implementation that is used for the hydration cache (SQL cache).
|
276 | 342 | *
|
| 343 | + * @deprecated Call {@see getHydrationCache()} instead. |
| 344 | + * |
277 | 345 | * @return CacheDriver|null
|
278 | 346 | */
|
279 | 347 | public function getHydrationCacheImpl()
|
280 | 348 | {
|
| 349 | + Deprecation::trigger( |
| 350 | + 'doctrine/orm', |
| 351 | + 'https://github.com/doctrine/orm/pull/9002', |
| 352 | + 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getHydrationCache() instead.', |
| 353 | + __METHOD__ |
| 354 | + ); |
| 355 | + |
281 | 356 | return $this->_attributes['hydrationCacheImpl'] ?? null;
|
282 | 357 | }
|
283 | 358 |
|
284 | 359 | /**
|
285 | 360 | * Sets the cache driver implementation that is used for the hydration cache (SQL cache).
|
286 | 361 | *
|
| 362 | + * @deprecated Call {@see setHydrationCache()} instead. |
| 363 | + * |
287 | 364 | * @return void
|
288 | 365 | */
|
289 | 366 | public function setHydrationCacheImpl(CacheDriver $cacheImpl)
|
290 | 367 | {
|
| 368 | + Deprecation::trigger( |
| 369 | + 'doctrine/orm', |
| 370 | + 'https://github.com/doctrine/orm/pull/9002', |
| 371 | + 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use setHydrationCache() instead.', |
| 372 | + __METHOD__ |
| 373 | + ); |
| 374 | + |
| 375 | + $this->_attributes['hydrationCache'] = CacheAdapter::wrap($cacheImpl); |
291 | 376 | $this->_attributes['hydrationCacheImpl'] = $cacheImpl;
|
292 | 377 | }
|
293 | 378 |
|
| 379 | + public function getHydrationCache(): ?CacheItemPoolInterface |
| 380 | + { |
| 381 | + return $this->_attributes['hydrationCache'] ?? null; |
| 382 | + } |
| 383 | + |
| 384 | + public function setHydrationCache(CacheItemPoolInterface $cache): void |
| 385 | + { |
| 386 | + $this->_attributes['hydrationCache'] = $cache; |
| 387 | + $this->_attributes['hydrationCacheImpl'] = DoctrineProvider::wrap($cache); |
| 388 | + } |
| 389 | + |
294 | 390 | /**
|
295 | 391 | * Gets the cache driver implementation that is used for metadata caching.
|
296 | 392 | *
|
|
0 commit comments