/** * Send notification for all users of the specified network. * @param $message * @param SocialNetwork $socialNetwork * @return array */ public function sendNotification($message, SocialNetwork $socialNetwork, $adminsOnly = false) { $api = $this->socialApis[(string) $socialNetwork]; $users = $adminsOnly ? $this->userRepository->findAdminsBySocialNetwork($socialNetwork) : $this->userRepository->findBySocialNetwork($socialNetwork); $userIds = array(); foreach ($users as $user) { $userIds[] = $user->getSocialId(); } return $api->sendNotification($message, $userIds); }
/** * Get current authenticated use or null. * @return User */ public function getUser() { if (!$this->isAuthenticated()) { return null; } $socialNetwork = $this->getSocialNetwork(); $user = $this->userRepository->find($this->getUserId()); if (isset($user)) { $user->setSocialNetwork($socialNetwork); } return $user; }