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 =
|
private static $_classTemplate =
|
||||||
'<?php
|
'<?php
|
||||||
|
|
||||||
<namespace><use>
|
<namespace>
|
||||||
|
|
||||||
<entityAnnotation>
|
<entityAnnotation>
|
||||||
<entityClassName>
|
<entityClassName>
|
||||||
@ -189,7 +189,6 @@ public function <methodName>()
|
|||||||
{
|
{
|
||||||
$placeHolders = array(
|
$placeHolders = array(
|
||||||
'<namespace>',
|
'<namespace>',
|
||||||
'<use>',
|
|
||||||
'<entityAnnotation>',
|
'<entityAnnotation>',
|
||||||
'<entityClassName>',
|
'<entityClassName>',
|
||||||
'<entityBody>'
|
'<entityBody>'
|
||||||
@ -197,7 +196,6 @@ public function <methodName>()
|
|||||||
|
|
||||||
$replacements = array(
|
$replacements = array(
|
||||||
$this->_generateEntityNamespace($metadata),
|
$this->_generateEntityNamespace($metadata),
|
||||||
$this->_generateEntityUse($metadata),
|
|
||||||
$this->_generateEntityDocBlock($metadata),
|
$this->_generateEntityDocBlock($metadata),
|
||||||
$this->_generateEntityClassName($metadata),
|
$this->_generateEntityClassName($metadata),
|
||||||
$this->_generateEntityBody($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)
|
private function _generateEntityClassName(ClassMetadataInfo $metadata)
|
||||||
{
|
{
|
||||||
return 'class ' . $this->_getClassName($metadata) .
|
return 'class ' . $this->_getClassName($metadata) .
|
||||||
|
@ -20,6 +20,7 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->_generator->setGenerateStubMethods(true);
|
$this->_generator->setGenerateStubMethods(true);
|
||||||
$this->_generator->setRegenerateEntityIfExists(false);
|
$this->_generator->setRegenerateEntityIfExists(false);
|
||||||
$this->_generator->setUpdateEntityIfExists(true);
|
$this->_generator->setUpdateEntityIfExists(true);
|
||||||
|
$this->_generator->setClassToExtend('stdClass');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWriteEntityClass()
|
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 getTest(') !== false);
|
||||||
$this->assertTrue(strstr($code, 'public function setTest(') !== 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');
|
unlink(__DIR__ . '/EntityGeneratorBook.php');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user