[DDC-1766] Cleaned up code.
This commit is contained in:
parent
d31c7f5e2b
commit
f7496b1482
@ -329,10 +329,12 @@ abstract class AbstractQuery
|
||||
public function setHydrationCacheProfile(QueryCacheProfile $profile = null)
|
||||
{
|
||||
if ( ! $profile->getResultCacheDriver()) {
|
||||
$profile = $profile->setResultCacheDriver($this->_em->getConfiguration()->getResultCacheImpl());
|
||||
$resultCacheDriver = $this->_em->getConfiguration()->getResultCacheImpl();
|
||||
$profile = $profile->setResultCacheDriver($resultCacheDriver);
|
||||
}
|
||||
|
||||
$this->_hydrationCacheProfile = $profile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -356,10 +358,12 @@ abstract class AbstractQuery
|
||||
public function setResultCacheProfile(QueryCacheProfile $profile = null)
|
||||
{
|
||||
if ( ! $profile->getResultCacheDriver()) {
|
||||
$profile = $profile->setResultCacheDriver($this->_em->getConfiguration()->getResultCacheImpl());
|
||||
$resultCacheDriver = $this->_em->getConfiguration()->getResultCacheImpl();
|
||||
$profile = $profile->setResultCacheDriver($resultCacheDriver);
|
||||
}
|
||||
|
||||
$this->_queryCacheProfile = $profile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -709,13 +713,14 @@ abstract class AbstractQuery
|
||||
}
|
||||
|
||||
$setCacheEntry = function() {};
|
||||
|
||||
if ($this->_hydrationCacheProfile !== null) {
|
||||
list($cacheKey, $realCacheKey) = $this->getHydrationCacheId();
|
||||
|
||||
$qcp = $this->getHydrationCacheProfile();
|
||||
$cache = $qcp->getResultCacheDriver();
|
||||
|
||||
$qcp = $this->getHydrationCacheProfile();
|
||||
$cache = $qcp->getResultCacheDriver();
|
||||
$result = $cache->fetch($cacheKey);
|
||||
|
||||
if (isset($result[$realCacheKey])) {
|
||||
return $result[$realCacheKey];
|
||||
}
|
||||
@ -734,6 +739,7 @@ abstract class AbstractQuery
|
||||
|
||||
if (is_numeric($stmt)) {
|
||||
$setCacheEntry($stmt);
|
||||
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
@ -756,6 +762,7 @@ abstract class AbstractQuery
|
||||
protected function getHydrationCacheId()
|
||||
{
|
||||
$params = $this->getParameters();
|
||||
|
||||
foreach ($params AS $key => $value) {
|
||||
if (is_object($value) && $this->_em->getMetadataFactory()->hasMetadataFor(get_class($value))) {
|
||||
if ($this->_em->getUnitOfWork()->getEntityState($value) == UnitOfWork::STATE_MANAGED) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user