public function removeTag(File $file, Tag $tag) { foreach ($file->getFileTags() as $tagRelation) { if ($tagRelation->getTag()->getId() == $tag->getId()) { $this->em->remove($tagRelation); } } }