From 6a428c6064fa0104edee8696dd456f5990d748fb Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Sat, 20 Jun 2015 13:36:23 +0200 Subject: [PATCH] Allow to retreive association cache defaults --- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index dd47c9788..1dfb93349 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -1078,18 +1078,29 @@ class ClassMetadataInfo implements ClassMetadata * @return void */ public function enableAssociationCache($fieldName, array $cache) + { + $this->associationMappings[$fieldName]['cache'] = $this->getAssociationCacheDefaults ($fieldName, $cache); + } + + /** + * @param string $fieldName + * @param array $cache + * + * @return array + */ + public function getAssociationCacheDefaults ($fieldName, array $cache) { if ( ! isset($cache['usage'])) { $cache['usage'] = isset($this->cache['usage']) - ? $this->cache['usage'] - : self::CACHE_USAGE_READ_ONLY; + ? $this->cache['usage'] + : self::CACHE_USAGE_READ_ONLY; } if ( ! isset($cache['region'])) { $cache['region'] = strtolower(str_replace('\\', '_', $this->rootEntityName)) . '__' . $fieldName; } - $this->associationMappings[$fieldName]['cache'] = $cache; + return $cache; } /**