public function getIterator() { $query = $this->getQuery($this->options['entity'], $this->options['query_method']); $results = $query->iterate(); // and populate the sitemap! while (($result = $results->next()) !== false) { (yield $this->resultToUrl($result[0])); $this->em->detach($result[0]); } }
/** * Selects a celestial body that should be used for a new player. * * @todo could use a better algorithm. Maybe place new players in areas that * are not too densly populated. * Or place them among other players just having started playing. * Currently, we simply take any celestial body that doesn't yet have * an owner. * * @return \common\models\TerrestrialPlanet */ public function getTerrestrialPlanetForNewPlayer() { $celestialBodyEntity = $this->celestialBodyRepository->findForNewPlayer(); if ($celestialBodyEntity instanceof TerrestrialPlanetEntity) { $terrestrialPlanetEntity = $celestialBodyEntity; } else { $this->em->detach($celestialBodyEntity); // This is the bad part. // Maybe there's a better alternative? $discrTerrestrialPlanet = CelestialBodyEntity::DISCR_TERRESTRIAL_PLANET; $query = "UPDATE celestialbody SET discr = {$discrTerrestrialPlanet} WHERE id = {$celestialBodyEntity->getId()}"; $this->em->getConnection()->exec($query); // this is now a terrestrial planet $terrestrialPlanetEntity = $this->celestialBodyRepository->find($celestialBodyEntity->getId()); } $terrestrialPlanetModel = CelestialBodyFactory::create($terrestrialPlanetEntity, $this->celestialBodySpecialtyRepository); $terrestrialPlanetModel->reset(); return $terrestrialPlanetModel; }