/** * @return UserAccount */ public static function getCurrentSession() { if (!empty(self::$currentUser)) { return self::$currentUser; } elseif (!empty(self::$session)) { try { self::$currentUser = UserAccount::getById(self::$session['id']); } catch (\NotFoundException $e) { self::unsetSession(); throw $e; } return self::$currentUser; } return null; }