Skip to content

Commit

Permalink
repository: RemovalHelper sets null to read-only properties [closes #331
Browse files Browse the repository at this point in the history
]
  • Loading branch information
hrach committed Jan 26, 2019
1 parent e179903 commit 7114bac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Repository/RemovalHelper.php
Expand Up @@ -133,15 +133,15 @@ private static function setNulls(IEntity $entity, array $metadata, IModel $model
: null;

if ($type === Relationship::MANY_HAS_MANY) {
/** @var ManyHasMany $property */
$property = $entity->getProperty($name);
assert($property instanceof ManyHasMany);
$pre[] = $property;
if ($reverseProperty !== null) {
foreach ($property as $reverseEntity) {
$pre[] = $reverseEntity->getProperty($reverseProperty->name);
}
}
$entity->setValue($name, []);
$entity->setReadOnlyValue($name, []);

} elseif ($type === Relationship::MANY_HAS_ONE || ($type === Relationship::ONE_HAS_ONE && $propertyMeta->relationship->isMain)) {
$property = $entity->getProperty($name);
Expand Down

0 comments on commit 7114bac

Please sign in to comment.