Skip to content

Commit 99e6c06

Browse files
authored
Update MonarcObject.php
Added the validation of missing anr link before updating of the objects.
1 parent 877c088 commit 99e6c06

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Model/Entity/MonarcObject.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* @ORM\Index(name="rolf_tag_id", columns={"rolf_tag_id"})
2222
* })
2323
* @ORM\Entity
24+
* @ORM\HasLifecycleCallbacks()
2425
*/
2526
class MonarcObject extends ObjectSuperClass
2627
{
@@ -59,4 +60,16 @@ class MonarcObject extends ObjectSuperClass
5960
* })
6061
*/
6162
protected $asset;
63+
64+
/**
65+
* @ORM\PreUpdate
66+
*/
67+
public function validateAndSetMissingAnrLink(): self
68+
{
69+
if (!$this->anrs->contains($this->anr)) {
70+
$this->anrs->add($this->anr);
71+
}
72+
73+
return $this;
74+
}
6275
}

0 commit comments

Comments
 (0)