/** * get last notification for a give user id * @param int $userId [description] * @return array | null */ protected function getLastNotification($userId) { $rez = null; //save current user id $currentUser = $_SESSION['user']['id']; $api = new \CB\Api\Notifications(); $result = $api->getList(array('limit' => 900)); if ($result['success'] == true && !empty($result['data'])) { $rez = array_shift($result['data']); } //restore previous user id $_SESSION['user']['id'] = $currentUser; return $rez; }