I use the following code for my many-to-many relation in symfony2 (doctrine)
Entity:
/**
* @ORM\ManyToMany(targetEntity="BizTV\ContainerManagementBundle\Entity\Container", inversedBy="videosToSync")
* @ORM\JoinTable(name="syncSchema")
*/
private $syncSchema;
public function __construct()
{
$this->syncSchema = new \Doctrine\Common\Collections\ArrayCollection();
}
public function addSyncSchema(\BizTV\ContainerManagementBundle\Entity\Container $syncSchema)
{
$this->syncSchema[] = $syncSchema;
}
Controller:
$entity->addSyncSchema($container);
$em->flush();
Now, how can I use this to remove a relation? Do I need to add a method to my entity like removeSyncSchema()? What would that look like?