Skip to content

Commit

Permalink
- Added entity builder for sub entity
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec committed Jun 22, 2019
1 parent c77a796 commit 09f78e5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/IPub/DoctrineCrud/Mapping/EntityMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,13 @@ public function fillEntity(Utils\ArrayHash $values, Entities\IEntity $entity, bo
if ($constructor = $rc->getConstructor()) {
$subEntity = $rc->newInstanceArgs(Helpers::autowireArguments($constructor, array_merge((array) $value, ['parent_entity' => $entity])));

$this->setFieldValue($classMetadata, $entity, $fieldName, $subEntity);

} else {
$this->setFieldValue($classMetadata, $entity, $fieldName, new $className);
$subEntity = new $className;
}

$this->setFieldValue($classMetadata, $entity, $fieldName, $this->fillEntity(Utils\ArrayHash::from(array_merge((array) $value, [$this->findAttributeName($entity, $className) => $entity])), $subEntity, TRUE));

} else {
$this->setFieldValue($classMetadata, $entity, $fieldName, $value);
}
Expand Down

0 comments on commit 09f78e5

Please sign in to comment.