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