My purpose is to remove the record in the entity artist only if there are no other records of the entity connected soundtrack.
I tried with orphanRemoval in 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
/**
* @ORM\ManyToMany(targetEntity="Soundtrack", mappedBy="artists")
*/
private $soundtrack;
but when I delete an entity record soundtrack, also clears the record of the entity artist even if it is linked to other records soundtrack (I think this is what you should expect from orphanRemoval).
Is there a way to remove that record an "orphan" only when no other records connected?
I also tried just 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 records entity artist ..