DDC-770 - Refactored EntityGenerator Bugfix NOT to generate a use statement. Simplifies code and circumvents further problems (like importing a class from the namespace we are in)
This commit is contained in:
parent
2a2936fde5
commit
c77a12ac83
@ -82,7 +82,7 @@ class EntityGenerator
|
||||
private static $_classTemplate =
|
||||
'<?php
|
||||
|
||||
<namespace><use>
|
||||
<namespace>
|
||||
|
||||
<entityAnnotation>
|
||||
<entityClassName>
|
||||
@ -189,7 +189,6 @@ public function <methodName>()
|
||||
{
|
||||
$placeHolders = array(
|
||||
'<namespace>',
|
||||
'<use>',
|
||||
'<entityAnnotation>',
|
||||
'<entityClassName>',
|
||||
'<entityBody>'
|
||||
@ -197,7 +196,6 @@ public function <methodName>()
|
||||
|
||||
$replacements = array(
|
||||
$this->_generateEntityNamespace($metadata),
|
||||
$this->_generateEntityUse($metadata),
|
||||
$this->_generateEntityDocBlock($metadata),
|
||||
$this->_generateEntityClassName($metadata),
|
||||
$this->_generateEntityBody($metadata)
|
||||
@ -309,13 +307,6 @@ public function <methodName>()
|
||||
}
|
||||
}
|
||||
|
||||
private function _generateEntityUse(ClassMetadataInfo $metadata)
|
||||
{
|
||||
if ($this->_extendsClass()) {
|
||||
return "\n\nuse " . $this->_getClassToExtendName() . ";\n";
|
||||
}
|
||||
}
|
||||
|
||||
private function _generateEntityClassName(ClassMetadataInfo $metadata)
|
||||
{
|
||||
return 'class ' . $this->_getClassName($metadata) .
|
||||
|
@ -20,6 +20,7 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->_generator->setGenerateStubMethods(true);
|
||||
$this->_generator->setRegenerateEntityIfExists(false);
|
||||
$this->_generator->setUpdateEntityIfExists(true);
|
||||
$this->_generator->setClassToExtend('stdClass');
|
||||
}
|
||||
|
||||
public function testWriteEntityClass()
|
||||
@ -100,6 +101,18 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertTrue(strstr($code, 'public function getTest(') !== false);
|
||||
$this->assertTrue(strstr($code, 'public function setTest(') !== false);
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testEntityUpdatingWorks
|
||||
* @param ClassMetadata $metadata
|
||||
*/
|
||||
public function testEntityExtendsStdClass($metadata)
|
||||
{
|
||||
$book = new \EntityGeneratorBook();
|
||||
$this->assertType('stdClass', $book);
|
||||
|
||||
unlink(__DIR__ . '/EntityGeneratorBook.php');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user