redis = $redis_prov->getRedisClient(); $this->redis_mqtt_key = $redis_mqtt_key; $this->em = $em; } // set user_id to 0 for all public function sendNotification($user_id, $msg, $url) { // send mqtt $chan = $this->getChannel($user_id); $data = $chan . '|' . $msg; $this->redis->lpush($this->redis_mqtt_key, $data); // create notif $notif = new Notification(); $notif->setUserID($user_id) ->setIcon('') ->setMessage($msg) ->setURL($url); // save to db $this->em->persist($notif); $this->em->flush(); } protected function getChannel($user_id) { return str_replace('{user_id}', $user_id, self::NOTIF_KEY ); } }