Merge pull request #1012 from FabioBatSilva/DDC-3078-slc-cache-interface-ctor-removal
Ddc 3078 slc cache interface ctor removal
This commit is contained in:
commit
6af3236ba6
@ -54,13 +54,6 @@ interface Cache
|
|||||||
*/
|
*/
|
||||||
const MODE_REFRESH = 4;
|
const MODE_REFRESH = 4;
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct
|
|
||||||
*
|
|
||||||
* @param \Doctrine\ORM\EntityManagerInterface $em
|
|
||||||
*/
|
|
||||||
public function __construct(EntityManagerInterface $em);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $className The entity class.
|
* @param string $className The entity class.
|
||||||
*
|
*
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
namespace Doctrine\ORM\Cache;
|
namespace Doctrine\ORM\Cache;
|
||||||
|
|
||||||
use Doctrine\ORM\ORMException;
|
|
||||||
use Doctrine\ORM\Cache\Logging\CacheLogger;
|
use Doctrine\ORM\Cache\Logging\CacheLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,11 +50,6 @@ class CacheConfiguration
|
|||||||
*/
|
*/
|
||||||
private $queryValidator;
|
private $queryValidator;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $cacheClassName = 'Doctrine\ORM\Cache\DefaultCache';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Doctrine\ORM\Cache\CacheFactory|null
|
* @return \Doctrine\ORM\Cache\CacheFactory|null
|
||||||
*/
|
*/
|
||||||
@ -129,28 +123,4 @@ class CacheConfiguration
|
|||||||
{
|
{
|
||||||
$this->queryValidator = $validator;
|
$this->queryValidator = $validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $className
|
|
||||||
*
|
|
||||||
* @throws \Doctrine\ORM\ORMException If is not a \Doctrine\ORM\Cache
|
|
||||||
*/
|
|
||||||
public function setCacheClassName($className)
|
|
||||||
{
|
|
||||||
$reflectionClass = new \ReflectionClass($className);
|
|
||||||
|
|
||||||
if ( ! $reflectionClass->implementsInterface('Doctrine\ORM\Cache')) {
|
|
||||||
throw ORMException::invalidSecondLevelCache($className);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->cacheClassName = $className;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string A \Doctrine\ORM\Cache class name
|
|
||||||
*/
|
|
||||||
public function getCacheClassName()
|
|
||||||
{
|
|
||||||
return $this->cacheClassName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -101,4 +101,13 @@ interface CacheFactory
|
|||||||
* @return \Doctrine\ORM\Cache\TimestampRegion The timestamp region.
|
* @return \Doctrine\ORM\Cache\TimestampRegion The timestamp region.
|
||||||
*/
|
*/
|
||||||
public function getTimestampRegion();
|
public function getTimestampRegion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build \Doctrine\ORM\Cache
|
||||||
|
*
|
||||||
|
* @param EntityManagerInterface $entityManager
|
||||||
|
*
|
||||||
|
* @return \Doctrine\ORM\Cache
|
||||||
|
*/
|
||||||
|
public function createCache(EntityManagerInterface $entityManager);
|
||||||
}
|
}
|
||||||
|
@ -230,4 +230,12 @@ class DefaultCacheFactory implements CacheFactory
|
|||||||
|
|
||||||
return $this->timestampRegion;
|
return $this->timestampRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function createCache(EntityManagerInterface $em)
|
||||||
|
{
|
||||||
|
return new DefaultCache($em);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,8 +166,9 @@ use Doctrine\Common\Util\ClassUtils;
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($config->isSecondLevelCacheEnabled()) {
|
if ($config->isSecondLevelCacheEnabled()) {
|
||||||
$cacheClass = $config->getSecondLevelCacheConfiguration()->getCacheClassName();
|
$cacheConfig = $config->getSecondLevelCacheConfiguration();
|
||||||
$this->cache = new $cacheClass($this);
|
$cacheFactory = $cacheConfig->getCacheFactory();
|
||||||
|
$this->cache = $cacheFactory->createCache($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,16 +262,6 @@ class ORMException extends Exception
|
|||||||
return new self("Invalid repository class '".$className."'. It must be a Doctrine\Common\Persistence\ObjectRepository.");
|
return new self("Invalid repository class '".$className."'. It must be a Doctrine\Common\Persistence\ObjectRepository.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $className
|
|
||||||
*
|
|
||||||
* @return ORMException
|
|
||||||
*/
|
|
||||||
public static function invalidSecondLevelCache($className)
|
|
||||||
{
|
|
||||||
return new self(sprintf('Invalid cache class "%s". It must be a Doctrine\ORM\Cache.', $className));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $className
|
* @param string $className
|
||||||
* @param string $fieldName
|
* @param string $fieldName
|
||||||
|
@ -7,6 +7,8 @@ use Doctrine\ORM\Cache\CacheConfiguration;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @group DDC-2183
|
* @group DDC-2183
|
||||||
|
*
|
||||||
|
* @covers \Doctrine\ORM\Cache\CacheConfiguration
|
||||||
*/
|
*/
|
||||||
class CacheConfigTest extends DoctrineTestCase
|
class CacheConfigTest extends DoctrineTestCase
|
||||||
{
|
{
|
||||||
@ -15,6 +17,9 @@ class CacheConfigTest extends DoctrineTestCase
|
|||||||
*/
|
*/
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@ -22,18 +27,6 @@ class CacheConfigTest extends DoctrineTestCase
|
|||||||
$this->config = new CacheConfiguration();
|
$this->config = new CacheConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetGetCacheClassName()
|
|
||||||
{
|
|
||||||
$mockClass = get_class($this->getMock('Doctrine\ORM\Cache'));
|
|
||||||
|
|
||||||
$this->assertEquals('Doctrine\ORM\Cache\DefaultCache', $this->config->getCacheClassName());
|
|
||||||
$this->config->setCacheClassName($mockClass);
|
|
||||||
$this->assertEquals($mockClass, $this->config->getCacheClassName());
|
|
||||||
|
|
||||||
$this->setExpectedException('Doctrine\ORM\ORMException');
|
|
||||||
$this->config->setCacheClassName(__CLASS__);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSetGetRegionLifetime()
|
public function testSetGetRegionLifetime()
|
||||||
{
|
{
|
||||||
$config = $this->config->getRegionsConfiguration();
|
$config = $this->config->getRegionsConfiguration();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user