public function createLeagueTeams(League $league) { for ($i = 0; $i < $league->getSize(); $i++) { $team = new Team(); $team->setName("New_Team_{$i}"); $team->setLeague($league); $this->em->persist($team); } $this->em->flush(); }