1
0
mirror of synced 2024-12-15 07:36:03 +03:00

Merge branch 'DDC-1771'

This commit is contained in:
Benjamin Eberlei 2012-04-07 10:30:17 +02:00
commit c92393026d
2 changed files with 25 additions and 1 deletions

View File

@ -125,22 +125,27 @@ class ProxyFactory
* @param string $toDir The target directory of the proxy classes. If not specified, the * @param string $toDir The target directory of the proxy classes. If not specified, the
* directory configured on the Configuration of the EntityManager used * directory configured on the Configuration of the EntityManager used
* by this factory is used. * by this factory is used.
* @return int Number of generated proxies.
*/ */
public function generateProxyClasses(array $classes, $toDir = null) public function generateProxyClasses(array $classes, $toDir = null)
{ {
$proxyDir = $toDir ?: $this->_proxyDir; $proxyDir = $toDir ?: $this->_proxyDir;
$proxyDir = rtrim($proxyDir, DIRECTORY_SEPARATOR); $proxyDir = rtrim($proxyDir, DIRECTORY_SEPARATOR);
$num = 0;
foreach ($classes as $class) { foreach ($classes as $class) {
/* @var $class ClassMetadata */ /* @var $class ClassMetadata */
if ($class->isMappedSuperclass) { if ($class->isMappedSuperclass || $class->reflClass->isAbstract()) {
continue; continue;
} }
$proxyFileName = $this->getProxyFileName($class->name, $proxyDir); $proxyFileName = $this->getProxyFileName($class->name, $proxyDir);
$this->_generateProxyClass($class, $proxyFileName, self::$_proxyClassTemplate); $this->_generateProxyClass($class, $proxyFileName, self::$_proxyClassTemplate);
$num++;
} }
return $num;
} }
/** /**

View File

@ -155,6 +155,20 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals(1, substr_count($classCode, 'function __sleep')); $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() public function testNoConfigDir_ThrowsException()
{ {
$this->setExpectedException('Doctrine\ORM\Proxy\ProxyException'); $this->setExpectedException('Doctrine\ORM\Proxy\ProxyException');
@ -183,3 +197,8 @@ class SleepClass
return array('id'); return array('id');
} }
} }
abstract class AbstractClass
{
}