Merge branch 'DDC-1771'
This commit is contained in:
commit
c92393026d
@ -125,22 +125,27 @@ class ProxyFactory
|
||||
* @param string $toDir The target directory of the proxy classes. If not specified, the
|
||||
* directory configured on the Configuration of the EntityManager used
|
||||
* by this factory is used.
|
||||
* @return int Number of generated proxies.
|
||||
*/
|
||||
public function generateProxyClasses(array $classes, $toDir = null)
|
||||
{
|
||||
$proxyDir = $toDir ?: $this->_proxyDir;
|
||||
$proxyDir = rtrim($proxyDir, DIRECTORY_SEPARATOR);
|
||||
$num = 0;
|
||||
|
||||
foreach ($classes as $class) {
|
||||
/* @var $class ClassMetadata */
|
||||
if ($class->isMappedSuperclass) {
|
||||
if ($class->isMappedSuperclass || $class->reflClass->isAbstract()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$proxyFileName = $this->getProxyFileName($class->name, $proxyDir);
|
||||
|
||||
$this->_generateProxyClass($class, $proxyFileName, self::$_proxyClassTemplate);
|
||||
$num++;
|
||||
}
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -155,6 +155,20 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertEquals(1, substr_count($classCode, 'function __sleep'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1771
|
||||
*/
|
||||
public function testSkipAbstractClassesOnGeneration()
|
||||
{
|
||||
$cm = new \Doctrine\ORM\Mapping\ClassMetadata(__NAMESPACE__ . '\\AbstractClass');
|
||||
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
||||
$this->assertNotNull($cm->reflClass);
|
||||
|
||||
$num = $this->_proxyFactory->generateProxyClasses(array($cm));
|
||||
|
||||
$this->assertEquals(0, $num, "No proxies generated.");
|
||||
}
|
||||
|
||||
public function testNoConfigDir_ThrowsException()
|
||||
{
|
||||
$this->setExpectedException('Doctrine\ORM\Proxy\ProxyException');
|
||||
@ -183,3 +197,8 @@ class SleepClass
|
||||
return array('id');
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractClass
|
||||
{
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user