My goal is to delete a record in the executor of an object only if there are no other records related to the essence of the soundtrack.
I tried with orphanRemoval this way:
Soundtrack.php
/** * @Assert\NotBlank(message = "soundtrack.artists.blank") * @ORM\ManyToMany(targetEntity="Artist", inversedBy="soundtrack", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\JoinTable(name="soundtrack_artist") * @ORM\OrderBy({"name" = "ASC"}) **/ private $artists;
Artist.php
private $soundtrack;
but when I delete the soundtrack to the entity record, it also clears the object's artist record, even if it is associated with the soundtrack to the other records (I think this is what you should expect from orphanRemoval).
Is there a way to delete this record "orphaned" only if no other records are connected?
I also tried like this:
**Soundtrack.php** /** * @Assert\NotBlank(message = "soundtrack.artists.blank") * @ORM\ManyToMany(targetEntity="Artist", inversedBy="soundtrack", cascade={"persist"}, orphanRemoval=true) * @ORM\JoinTable(name="soundtrack_artist") * @ORM\OrderBy({"name" = "ASC"}) **/ private $artists;
but does not delete the executor of the entity records.
source share