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