DDC-1268 - Singular add*() method name through using targetEntity shortname
This commit is contained in:
parent
fb11268255
commit
4796452b07
@ -686,7 +686,13 @@ public function <methodName>()
|
|||||||
|
|
||||||
private function _generateEntityStubMethod(ClassMetadataInfo $metadata, $type, $fieldName, $typeHint = null)
|
private function _generateEntityStubMethod(ClassMetadataInfo $metadata, $type, $fieldName, $typeHint = null)
|
||||||
{
|
{
|
||||||
|
if ($type == "add") {
|
||||||
|
$addMethod = explode("\\", $typeHint);
|
||||||
|
$addMethod = end($addMethod);
|
||||||
|
$methodName = $type . $addMethod;
|
||||||
|
} else {
|
||||||
$methodName = $type . Inflector::classify($fieldName);
|
$methodName = $type . Inflector::classify($fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->_hasMethod($methodName, $metadata)) {
|
if ($this->_hasMethod($methodName, $metadata)) {
|
||||||
return;
|
return;
|
||||||
|
@ -98,7 +98,7 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setAuthor'), "EntityGeneratorBook::setAuthor() missing.");
|
$this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setAuthor'), "EntityGeneratorBook::setAuthor() missing.");
|
||||||
$this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getAuthor'), "EntityGeneratorBook::getAuthor() missing.");
|
$this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getAuthor'), "EntityGeneratorBook::getAuthor() missing.");
|
||||||
$this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getComments'), "EntityGeneratorBook::getComments() missing.");
|
$this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getComments'), "EntityGeneratorBook::getComments() missing.");
|
||||||
$this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'addComments'), "EntityGeneratorBook::addComments() missing.");
|
$this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'addEntityGeneratorComment'), "EntityGeneratorBook::addEntityGeneratorComment() missing.");
|
||||||
|
|
||||||
$this->assertEquals('published', $book->getStatus());
|
$this->assertEquals('published', $book->getStatus());
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->assertEquals($author, $book->getAuthor());
|
$this->assertEquals($author, $book->getAuthor());
|
||||||
|
|
||||||
$comment = new EntityGeneratorComment();
|
$comment = new EntityGeneratorComment();
|
||||||
$book->addComments($comment);
|
$book->addEntityGeneratorComment($comment);
|
||||||
$this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $book->getComments());
|
$this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $book->getComments());
|
||||||
$this->assertEquals(new \Doctrine\Common\Collections\ArrayCollection(array($comment)), $book->getComments());
|
$this->assertEquals(new \Doctrine\Common\Collections\ArrayCollection(array($comment)), $book->getComments());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user