public function refreshStatus(Banner $banner, $status, $hot = null) { return true; $months = $banner->getMonths(); foreach ($months as $m) { $this->em->remove($m); } foreach ($status as $m => $s) { $date = new \DateTime($m . ' 00:00:00'); $month = new Month(); $month->setBanner($banner); $month->setDate($date); $month->setStatus($s); if ($hot) { if ($m == $hot['date']) { $month->setSale($hot['sale']); } } $this->em->persist($month); $this->em->flush($month); } }