예제 #1
0
 /**
  * @param EventArgs|LifecycleEventArgs $args
  */
 public function postPersist(LifecycleEventArgs $args)
 {
     $entity = $args->getObject();
     $em = $args->getObjectManager();
     if ($entity instanceof Comment) {
         if ($entity->getArticleId() != null) {
             if ($entity->getUserId()->getId() != $entity->getArticleId()->getUserId()->getId()) {
                 $n = new Notification();
                 $n->setUser($entity->getUserId())->setArticle($entity->getArticleId());
                 $em->persist($n);
                 $em->flush();
             }
         } else {
             if ($entity->getVideoId() != null) {
                 if ($entity->getUserId()->getId() != $entity->getVideoId()->getUserId()->getId()) {
                     $n = new Notification();
                     $n->setUser($entity->getUserId())->setVideo($entity->getVideoId());
                     $em->persist($n);
                     $em->flush();
                 }
             } else {
                 if ($entity->getLinkId() != null) {
                     if ($entity->getUserId()->getId() != $entity->getLinkId()->getUserId()->getId()) {
                         $n = new Notification();
                         $n->setUser($entity->getUserId())->setLink($entity->getLinkId());
                         $em->persist($n);
                         $em->flush();
                     }
                 }
             }
         }
     }
 }
예제 #2
0
 public function addNewNotification()
 {
     $manager = $this->em;
     $notification = new Notification();
     $notification->setSubject($this->subject);
     $notification->setBody($this->body);
     $notification->setUser($this->user);
     $manager->persist($notification);
     $manager->flush();
     return new Response('notification id ' . $notification->getId() . ' successfully created');
 }
예제 #3
0
 public function createLivestreamNotifications(Series $series)
 {
     $notifications = [];
     $mails = [];
     foreach ($series->getAbonnements() as $abonnement) {
         if ($abonnement->getLivestream()) {
             $notification = new Notification();
             $notification->setUser($abonnement->getUser());
             $notification->setSeries($series);
             $notification->setType(Notification::LIVESTREAM);
             $notifications[] = $notification;
             if ($abonnement->getSendMails()) {
                 $mails[] = $notification;
             }
         }
     }
     $this->sendMails(Notification::LIVESTREAM, $mails);
     $this->saveNotifications($notifications);
 }
예제 #4
0
파일: User.php 프로젝트: OKTOTV/FLUX2
 /**
  * Add notifications
  *
  * @param \AppBundle\Entity\Notification $notifications
  * @return User
  */
 public function addNotification(Notification $notification)
 {
     $this->notifications[] = $notification;
     $notification->setUser($this);
     return $this;
 }