Skip to content

Commit cc9bd8e

Browse files
committed
Automap properties in many-to-many and one-to-many relations
1 parent 9a37c6b commit cc9bd8e

File tree

3 files changed

+2
-16
lines changed

3 files changed

+2
-16
lines changed

src/LightQL/Annotations/ManyToManyAnnotation.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ class ManyToManyAnnotation extends Annotation
5555
*/
5656
public $entity;
5757

58-
/**
59-
* The entity property which map the many-to-many relation.
60-
*
61-
* @var string
62-
*/
63-
public $mappedBy;
64-
6558
/**
6659
* The referenced table name of the many-to-many relation.
6760
*

src/LightQL/Annotations/OneToManyAnnotation.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,4 @@ class OneToManyAnnotation extends Annotation
5454
* @var string
5555
*/
5656
public $entity;
57-
58-
/**
59-
* The entity property which map the many-to-many relation.
60-
*
61-
* @var string
62-
*/
63-
public $mappedBy;
6457
}

src/LightQL/Sessions/Facade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ private function _fetchManyToMany(&$entity, $property)
325325
{
326326
$manyToMany = Annotations::ofProperty($entity, $property, "@manyToMany");
327327
$referencedEntityAnnotations = Annotations::ofClass($manyToMany[0]->entity, "@entity");
328-
$mappedPropertyAnnotation = Annotations::ofProperty($manyToMany[0]->entity, $manyToMany[0]->mappedBy, "@manyToMany");
328+
$mappedPropertyAnnotation = Annotations::ofProperty($manyToMany[0]->entity, $this->_getCollectionPropertyName($this->getEntityClassName()), "@manyToMany");
329329

330330
if ($manyToMany[0]->referencedTable !== $mappedPropertyAnnotation[0]->referencedTable) {
331331
throw new EntityException("Inconsistent @manyToMany annotation. The referenced table is different on both sides.");
@@ -364,7 +364,7 @@ private function _fetchOneToMany(&$entity, $property)
364364
{
365365
$oneToMany = Annotations::ofProperty($entity, $property, "@oneToMany");
366366
$referencedEntityAnnotations = Annotations::ofClass($oneToMany[0]->entity, "@entity");
367-
$mappedPropertyAnnotation = Annotations::ofProperty($oneToMany[0]->entity, $oneToMany[0]->mappedBy, "@manyToOne");
367+
$mappedPropertyAnnotation = Annotations::ofProperty($oneToMany[0]->entity, $this->_getCollectionPropertyName($this->getEntityClassName()), "@manyToOne");
368368

369369
$lightql = $this->entityManager->getLightQL();
370370

0 commit comments

Comments
 (0)