/** * save word * * @param Word $word * @param string $name * @param array $results */ public function saveWord($word, $name, $results) { $em = $this->getEntityManager(); $word->check("anagram"); foreach ($results as $anagramName) { $anagram = $this->getWord($anagramName); $word->addAnagram($anagram); $em->persist($anagram); $em->flush(); unset($anagram); } $em->persist($word); $em->flush(); }