From 3865733e18421126de45ca91f221aebd628b1ccc Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 29 Oct 2022 21:33:15 -0400 Subject: [PATCH] Move Model\Profile::getMyUrl to UserSessions --- src/Core/Session/Capability/IHandleUserSessions.php | 7 +++++++ src/Core/Session/Model/UserSession.php | 6 ++++++ src/Model/Profile.php | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Core/Session/Capability/IHandleUserSessions.php b/src/Core/Session/Capability/IHandleUserSessions.php index 307b69492..e65749c8d 100644 --- a/src/Core/Session/Capability/IHandleUserSessions.php +++ b/src/Core/Session/Capability/IHandleUserSessions.php @@ -65,6 +65,13 @@ interface IHandleUserSessions extends IHandleSessions */ public function getUserIDForVisitorContactID(int $cid): int; + /** + * Returns the account URL of the currently logged in user + * + * @return string + */ + public function getMyUrl(): string; + /** * Returns if the current visitor is authenticated * diff --git a/src/Core/Session/Model/UserSession.php b/src/Core/Session/Model/UserSession.php index 79f5b2aae..959ca1af2 100644 --- a/src/Core/Session/Model/UserSession.php +++ b/src/Core/Session/Model/UserSession.php @@ -110,6 +110,12 @@ class UserSession implements IHandleUserSessions return array_search($cid, $this->session->get('remote')); } + /** {@inheritDoc} */ + public function getMyUrl(): string + { + return $this->session->get('my_url', ''); + } + /** {@inheritDoc} */ public function isAuthenticated(): bool { diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 96932cdb0..2129e92bd 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -679,10 +679,11 @@ class Profile * Retrieves the my_url session variable * * @return string + * @deprecated since version 2022.12, please use UserSession->getMyUrl instead */ public static function getMyURL(): string { - return DI::session()->get('my_url') ?? ''; + return DI::userSession()->getMyUrl(); } /**