[DDC-642] Fixes issue with exporters not including inversedBy functionality
This commit is contained in:
parent
e6f465ec80
commit
20c1ff3146
@ -698,6 +698,10 @@ public function <methodName>()
|
|||||||
$typeOptions[] = 'targetEntity="' . $associationMapping->targetEntityName . '"';
|
$typeOptions[] = 'targetEntity="' . $associationMapping->targetEntityName . '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($associationMapping->inversedBy)) {
|
||||||
|
$typeOptions[] = 'inversedBy="' . $associationMapping->inversedBy . '"';
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($associationMapping->mappedBy)) {
|
if (isset($associationMapping->mappedBy)) {
|
||||||
$typeOptions[] = 'mappedBy="' . $associationMapping->mappedBy . '"';
|
$typeOptions[] = 'mappedBy="' . $associationMapping->mappedBy . '"';
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,7 @@ class PhpExporter extends AbstractExporter
|
|||||||
$method = 'mapOneToOne';
|
$method = 'mapOneToOne';
|
||||||
$oneToOneMappingArray = array(
|
$oneToOneMappingArray = array(
|
||||||
'mappedBy' => $associationMapping->mappedBy,
|
'mappedBy' => $associationMapping->mappedBy,
|
||||||
|
'inversedBy' => $associationMapping->inversedBy,
|
||||||
'joinColumns' => $associationMapping->joinColumns,
|
'joinColumns' => $associationMapping->joinColumns,
|
||||||
'orphanRemoval' => $associationMapping->orphanRemoval,
|
'orphanRemoval' => $associationMapping->orphanRemoval,
|
||||||
);
|
);
|
||||||
|
@ -196,6 +196,9 @@ class XmlExporter extends AbstractExporter
|
|||||||
if (isset($associationMapping->mappedBy)) {
|
if (isset($associationMapping->mappedBy)) {
|
||||||
$associationMappingXml->addAttribute('mapped-by', $associationMapping->mappedBy);
|
$associationMappingXml->addAttribute('mapped-by', $associationMapping->mappedBy);
|
||||||
}
|
}
|
||||||
|
if (isset($associationMapping->inversedBy)) {
|
||||||
|
$associationMappingXml->addAttribute('inversed-by', $associationMapping->inversedBy);
|
||||||
|
}
|
||||||
if (isset($associationMapping->orphanRemoval)) {
|
if (isset($associationMapping->orphanRemoval)) {
|
||||||
$associationMappingXml->addAttribute('orphan-removal', $associationMapping->orphanRemoval);
|
$associationMappingXml->addAttribute('orphan-removal', $associationMapping->orphanRemoval);
|
||||||
}
|
}
|
||||||
|
@ -168,6 +168,7 @@ class YamlExporter extends AbstractExporter
|
|||||||
}
|
}
|
||||||
$oneToOneMappingArray = array(
|
$oneToOneMappingArray = array(
|
||||||
'mappedBy' => $associationMapping->mappedBy,
|
'mappedBy' => $associationMapping->mappedBy,
|
||||||
|
'inversedBy' => $associationMapping->inversedBy,
|
||||||
'joinColumns' => $newJoinColumns,
|
'joinColumns' => $newJoinColumns,
|
||||||
'orphanRemoval' => $associationMapping->orphanRemoval,
|
'orphanRemoval' => $associationMapping->orphanRemoval,
|
||||||
);
|
);
|
||||||
@ -177,6 +178,7 @@ class YamlExporter extends AbstractExporter
|
|||||||
} else if ($associationMapping instanceof OneToManyMapping) {
|
} else if ($associationMapping instanceof OneToManyMapping) {
|
||||||
$oneToManyMappingArray = array(
|
$oneToManyMappingArray = array(
|
||||||
'mappedBy' => $associationMapping->mappedBy,
|
'mappedBy' => $associationMapping->mappedBy,
|
||||||
|
'inversedBy' => $associationMapping->inversedBy,
|
||||||
'orphanRemoval' => $associationMapping->orphanRemoval,
|
'orphanRemoval' => $associationMapping->orphanRemoval,
|
||||||
'orderBy' => $associationMapping->orderBy
|
'orderBy' => $associationMapping->orderBy
|
||||||
);
|
);
|
||||||
@ -185,8 +187,9 @@ class YamlExporter extends AbstractExporter
|
|||||||
$array['oneToMany'][$name] = $associationMappingArray;
|
$array['oneToMany'][$name] = $associationMappingArray;
|
||||||
} else if ($associationMapping instanceof ManyToManyMapping) {
|
} else if ($associationMapping instanceof ManyToManyMapping) {
|
||||||
$manyToManyMappingArray = array(
|
$manyToManyMappingArray = array(
|
||||||
'mappedBy' => $associationMapping->mappedBy,
|
'mappedBy' => $associationMapping->mappedBy,
|
||||||
'joinTable' => $associationMapping->joinTable,
|
'inversedBy' => $associationMapping->inversedBy,
|
||||||
|
'joinTable' => $associationMapping->joinTable,
|
||||||
'orderBy' => $associationMapping->orderBy
|
'orderBy' => $associationMapping->orderBy
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -102,7 +102,9 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
|
|||||||
$cmf = $this->_createClassMetadataFactory($em, $type);
|
$cmf = $this->_createClassMetadataFactory($em, $type);
|
||||||
$metadata = $cmf->getAllMetadata();
|
$metadata = $cmf->getAllMetadata();
|
||||||
|
|
||||||
$this->assertEquals('Doctrine\Tests\ORM\Tools\Export\User', $metadata[0]->name);
|
$metadata[0]->name = 'Doctrine\Tests\ORM\Tools\Export\ExportedUser';
|
||||||
|
|
||||||
|
$this->assertEquals('Doctrine\Tests\ORM\Tools\Export\ExportedUser', $metadata[0]->name);
|
||||||
|
|
||||||
$type = $this->_getType();
|
$type = $this->_getType();
|
||||||
$cme = new ClassMetadataExporter();
|
$cme = new ClassMetadataExporter();
|
||||||
@ -117,9 +119,9 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
|
|||||||
$exporter->export();
|
$exporter->export();
|
||||||
|
|
||||||
if ($type == 'annotation') {
|
if ($type == 'annotation') {
|
||||||
$this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/'.str_replace('\\', '/', 'Doctrine\Tests\ORM\Tools\Export\User').$this->_extension));
|
$this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/'.str_replace('\\', '/', 'Doctrine\Tests\ORM\Tools\Export\ExportedUser').$this->_extension));
|
||||||
} else {
|
} else {
|
||||||
$this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.User'.$this->_extension));
|
$this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser'.$this->_extension));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,14 +132,14 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
|
|||||||
{
|
{
|
||||||
$type = $this->_getType();
|
$type = $this->_getType();
|
||||||
|
|
||||||
$metadataDriver = $this->_createMetadataDriver($type, __DIR__ . '/' . $type);
|
$metadataDriver = $this->_createMetadataDriver($type, __DIR__ . '/export/' . $type);
|
||||||
$em = $this->_createEntityManager($metadataDriver);
|
$em = $this->_createEntityManager($metadataDriver);
|
||||||
$cmf = $this->_createClassMetadataFactory($em, $type);
|
$cmf = $this->_createClassMetadataFactory($em, $type);
|
||||||
$metadata = $cmf->getAllMetadata();
|
$metadata = $cmf->getAllMetadata();
|
||||||
|
|
||||||
$class = current($metadata);
|
$class = current($metadata);
|
||||||
|
|
||||||
$this->assertEquals('Doctrine\Tests\ORM\Tools\Export\User', $class->name);
|
$this->assertEquals('Doctrine\Tests\ORM\Tools\Export\ExportedUser', $class->name);
|
||||||
|
|
||||||
return $class;
|
return $class;
|
||||||
}
|
}
|
||||||
@ -304,6 +306,15 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
|
|||||||
return $class;
|
return $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testCascadeIsExported
|
||||||
|
* @param ClassMetadataInfo $class
|
||||||
|
*/
|
||||||
|
public function testInversedByIsExported($class)
|
||||||
|
{
|
||||||
|
$this->assertEquals('user', $class->associationMappings['address']->inversedBy);
|
||||||
|
}
|
||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
$type = $this->_getType();
|
$type = $this->_getType();
|
||||||
|
@ -23,7 +23,7 @@ class User
|
|||||||
public $email;
|
public $email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @OneToOne(targetEntity="Doctrine\Tests\ORM\Tools\Export\Address", cascade={"remove"})
|
* @OneToOne(targetEntity="Doctrine\Tests\ORM\Tools\Export\Address", cascade={"remove"}, inversedBy="user")
|
||||||
* @JoinColumn(name="address_id", onDelete="CASCADE", onUpdate="CASCADE")
|
* @JoinColumn(name="address_id", onDelete="CASCADE", onUpdate="CASCADE")
|
||||||
*/
|
*/
|
||||||
public $address;
|
public $address;
|
||||||
|
@ -34,6 +34,7 @@ $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
|
|||||||
$metadata->mapOneToOne(array(
|
$metadata->mapOneToOne(array(
|
||||||
'fieldName' => 'address',
|
'fieldName' => 'address',
|
||||||
'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\Export\\Address',
|
'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\Export\\Address',
|
||||||
|
'inversedBy' => 'user',
|
||||||
'cascade' =>
|
'cascade' =>
|
||||||
array(
|
array(
|
||||||
0 => 'remove',
|
0 => 'remove',
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<field name="name" column="name" type="string" length="50" nullable="true" unique="true" />
|
<field name="name" column="name" type="string" length="50" nullable="true" unique="true" />
|
||||||
<field name="email" column="user_email" type="string" column-definition="CHAR(32) NOT NULL" />
|
<field name="email" column="user_email" type="string" column-definition="CHAR(32) NOT NULL" />
|
||||||
|
|
||||||
<one-to-one field="address" target-entity="Doctrine\Tests\ORM\Tools\Export\Address">
|
<one-to-one field="address" target-entity="Doctrine\Tests\ORM\Tools\Export\Address" inversed-by="user">
|
||||||
<cascade><cascade-remove /></cascade>
|
<cascade><cascade-remove /></cascade>
|
||||||
<join-column name="address_id" referenced-column-name="id" on-delete="CASCADE" on-update="CASCADE"/>
|
<join-column name="address_id" referenced-column-name="id" on-delete="CASCADE" on-update="CASCADE"/>
|
||||||
</one-to-one>
|
</one-to-one>
|
||||||
|
@ -25,6 +25,7 @@ Doctrine\Tests\ORM\Tools\Export\User:
|
|||||||
onDelete: CASCADE
|
onDelete: CASCADE
|
||||||
onUpdate: CASCADE
|
onUpdate: CASCADE
|
||||||
cascade: [ remove ]
|
cascade: [ remove ]
|
||||||
|
inversedBy: user
|
||||||
oneToMany:
|
oneToMany:
|
||||||
phonenumbers:
|
phonenumbers:
|
||||||
targetEntity: Doctrine\Tests\ORM\Tools\Export\Phonenumber
|
targetEntity: Doctrine\Tests\ORM\Tools\Export\Phonenumber
|
||||||
|
Loading…
x
Reference in New Issue
Block a user