/** * @param array $data * * @return Notification */ public function create($data) { $notification = new Notification(); $notification->setName(Notification::LEADER_WISH); $notification->setContent(array('wish' => $data['wish'], 'userFullName' => $data['userFullName'], 'user' => $data['user'], 'restaurant' => $data['restaurant'], 'restaurantName' => $data['restaurantName'], 'image' => $data['image'])); $translatedMessage = $this->translator->trans($notification->getTranslationKey(), array('%name%' => $data['userFullName'], '%restaurant%' => $data['restaurantName'])); $notification->setMessage($translatedMessage); $followersIds = $this->userRepository->getFollowersIdsWithWish($data['user'], $data['wish']); foreach ($followersIds as $followersId) { $this->addPushMessage($notification, $followersId); } return $notification; }
/** * @param array $data * * @return Notification */ public function create($data) { $notification = new Notification(); $notification->setName(Notification::LEADER_FOLLOWS); $notification->setContent(array('follower' => $data['follower'], 'followerFullName' => $data['followerFullName'], 'leader' => $data['leader'], 'leaderFullName' => $data['leaderFullName'], 'image' => $data["followerImage"])); $followersIds = $this->userRepository->getFollowersIds($data['follower']); $translatedMessage = $this->translator->trans($notification->getTranslationKey(), array('%name%' => $data['followerFullName'], '%leader%' => $data['leaderFullName'])); $notification->setMessage($translatedMessage); foreach ($followersIds as $followerId) { $this->addPushMessage($notification, $followerId); } return $notification; }
/** * @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 */ public function create($data) { $userId = $data['user']; $reviewId = $data['review']; $newTaggedFriendsIdsString = $data['newTaggedFriends']; $notification = new Notification(); $notification->setName(Notification::NEW_TAGGED_FRIENDS); $notification->setContent(array('review' => $reviewId, 'restaurant' => $data['restaurant'], 'restaurantName' => $data['restaurantName'], 'user' => $data['user'], 'userFullName' => $data['userFullName'], 'image' => $data['image'])); $translatedMessage = $this->translator->trans($notification->getTranslationKey(), array('%name%' => $data['userFullName'], '%restaurant%' => $data['restaurantName'])); $notification->setMessage($translatedMessage); $newTaggedFriendsIds = explode(',', $newTaggedFriendsIdsString); foreach ($newTaggedFriendsIds as $newTaggedFriendId) { $this->addPushMessage($notification, $newTaggedFriendId); } 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; }