/**
  * @param Notification $notification
  * @param int          $userId
  */
 protected function addPushMessage(Notification $notification, $userId)
 {
     $pushMessage = new PushMessage();
     $pushMessage->setNotification($notification);
     $pushMessage->setUser($this->entityManager->getReference(User::CLASS_NAME, $userId));
     $notification->addPushMessage($pushMessage);
 }
コード例 #2
0
 /**
  * @param Notification $notification
  * @param int          $userId
  */
 protected function addPushMessage(Notification $notification, $userId)
 {
     if ($this->frequencyFilter->filter($userId)) {
         return;
     }
     $this->frequencyFilter->addPushedUser($userId);
     $pushMessage = new PushMessage();
     $pushMessage->setNotification($notification);
     $pushMessage->setUser($this->entityManager->getReference(User::CLASS_NAME, $userId));
     $notification->addPushMessage($pushMessage);
 }
コード例 #3
0
 /**
  * @param array $data
  *
  * @return Notification
  */
 public function create($data)
 {
     $leaderId = $data['leader'];
     $notification = new Notification();
     $notification->setName(Notification::NEW_FOLLOWER);
     $notification->setContent(array('follower' => $data['follower'], 'followerFullName' => $data['followerFullName'], 'image' => $data['followerImage']));
     $translatedMessage = $this->translator->trans($notification->getTranslationKey(), array('%name%' => $data['followerFullName']));
     $notification->setMessage($translatedMessage);
     $pushMessage = new PushMessage();
     $pushMessage->setNotification($notification);
     $pushMessage->setUser($this->entityManager->getReference(User::CLASS_NAME, $leaderId));
     $notification->addPushMessage($pushMessage);
     return $notification;
 }
 /**
  * @param array $data
  *
  * @return Notification
  * @throws \Exception
  */
 public function create($data)
 {
     $userId = $data['user'];
     $user = $this->userRepository->get($userId);
     $credential = $user->getCredentialByProvider(CredentialProvider::FACEBOOK);
     $friends = array();
     if ($credential) {
         $this->facebookClient->connect($credential->getToken());
         $friendsIds = $this->facebookClient->getFriendsIds();
         $friends = $this->userRepository->getUsersByCredentialExternalIds(CredentialProvider::FACEBOOK, $friendsIds);
     }
     $notification = new Notification();
     $notification->setName(Notification::NEW_FACEBOOK_FRIEND);
     $notification->setContent(array('user' => $userId, 'userFullName' => $data['userFullName'], 'image' => $data['image']));
     $translatedMessage = $this->translator->trans($notification->getTranslationKey(), array('%name%' => $data['userFullName']));
     $notification->setMessage($translatedMessage);
     foreach ($friends as $friend) {
         $pushMessage = new PushMessage();
         $pushMessage->setNotification($notification);
         $pushMessage->setUser($friend);
         $notification->addPushMessage($pushMessage);
     }
     return $notification;
 }