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