Exemplo n.º 1
0
 public function createNewEpisodeNotifications(Episode $episode)
 {
     $notifications = [];
     $mails = [];
     foreach ($episode->getSeries()->getAbonnements() as $abonnement) {
         if ($abonnement->getNewEpisode()) {
             $notification = new Notification();
             $notification->setEpisode($episode);
             $notification->setType(Notification::NEW_EPISODE);
             $abonnement->getUser()->addNotification($notification);
             $notifications[] = $notification;
             if ($abonnement->getSendMails()) {
                 $mails[] = $notification;
             }
         }
     }
     $this->sendMails(Notification::NEW_EPISODE, $mails);
     $this->saveNotifications($notifications);
 }