Exemplo n.º 1
0
 public function inviteSent(ActionInviteEvent $event)
 {
     $notification = new Notification();
     $notification->setUser($event->getReceiver())->setActions(json_encode(['accept' => '$scope.post("api/actions/invites/' . $event->getInvite()->getId() . '/accept")', 'reject' => '$scope.post("api/actions/invites/' . $event->getInvite()->getId() . '/reject")']))->setText('Вас пригласили в дело')->setIcon('abc');
     $this->em->persist($notification);
     $this->em->flush();
 }
Exemplo n.º 2
0
 public function firstActionDone(ActionEvent $event)
 {
     $this->doneCount = $this->em->getRepository('AcmeEdelaBundle:Action')->getDoneCount($event->getUser());
     $achievement = $this->em->getRepository('AcmeEdelaBundle:Achievement')->findOneBy(['tkey' => 'first-action-done']);
     if (!$achievement) {
         return;
     }
     if (!($userAchievement = $event->getUser()->getUserAchievements()->matching(Criteria::create()->where(Criteria::expr()->eq('achievement', $achievement)))->first())) {
         $userAchievement = new UserAchievement();
         $userAchievement->setProgress(100)->setUser($event->getUser())->setAchievement($achievement);
         $this->em->persist($userAchievement);
         $this->em->getRepository('AcmeUserBundle:User')->increaseExp($event->getUser(), $achievement->getExpReward());
         $this->em->persist($event->getUser());
         $notification = new Notification();
         $notification->setUser($event->getUser())->setActions(json_encode(['default' => '$scope.goto("achievements")']))->setText('Вы заработали достижение')->setIcon($achievement->getImage());
         $this->em->persist($notification);
     }
     $this->em->flush();
 }