Skip to content

Commit c655d0a

Browse files
Merge pull request #191 from edmondscommerce/ForceInitialization
Added initialization to remove from entity collection method
2 parents 4a8ee3a + 8a6667a commit c655d0a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Entity/Traits/ImplementNotifyChangeTrackingPolicy.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Doctrine\Common\PropertyChangedListener;
88
use Doctrine\ORM\EntityManagerInterface;
99
use Doctrine\ORM\Mapping\ClassMetadata;
10+
use Doctrine\ORM\PersistentCollection;
1011
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\EntityInterface;
1112
use EdmondsCommerce\DoctrineStaticMeta\Exception\ValidationException;
1213

@@ -166,6 +167,9 @@ private function removeFromEntityCollectionAndNotify(string $propName, EntityInt
166167
if ($this->$propName === null) {
167168
$this->$propName = new ArrayCollection();
168169
}
170+
if ($this->$propName instanceof PersistentCollection) {
171+
$this->$propName->initialize();
172+
}
169173
if (!$this->$propName->contains($entity)) {
170174
return;
171175
}

0 commit comments

Comments
 (0)