From 9b1278fbe5e343600a196ffd1bd385c50c3716e4 Mon Sep 17 00:00:00 2001 From: wordish <42463480+wordish@users.noreply.github.com> Date: Fri, 9 Aug 2024 15:35:29 -0700 Subject: [PATCH] Update UserInfo.php deal with static method calls --- concrete/src/User/UserInfo.php | 70 ++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 21 deletions(-) diff --git a/concrete/src/User/UserInfo.php b/concrete/src/User/UserInfo.php index 625bdc3b1ff..a38fcbab43b 100644 --- a/concrete/src/User/UserInfo.php +++ b/concrete/src/User/UserInfo.php @@ -1111,65 +1111,93 @@ protected function getDirector() } /** - * @deprecated Use app()->make('user/registration')->create() + * @deprecated Use $app->make('user/registration')->create() */ public static function add($data) { - $this->application ??= Facade::getFacadeApplication(); - return $this->application->make('user/registration')->create($data); + if (isset($this) && get_class($this) == __CLASS__) { + $app = $this->application + } else { + $app = Facade::getFacadeApplication(); + } + return $app->make('user/registration')->create($data); } /** - * @deprecated Use app()->make('user/registration')->createSuperUser() + * @deprecated Use $app->make('user/registration')->createSuperUser() */ public static function addSuperUser($uPasswordEncrypted, $uEmail) { - $this->application ??= Facade::getFacadeApplication(); - return $this->application->make('user/registration')->createSuperUser($uPasswordEncrypted, $uEmail); + if (isset($this) && get_class($this) == __CLASS__) { + $app = $this->application + } else { + $app = Facade::getFacadeApplication(); + } + return $app->make('user/registration')->createSuperUser($uPasswordEncrypted, $uEmail); } /** - * @deprecated Use app()->make('user/registration')->createFromPublicRegistration() + * @deprecated Use $app->make('user/registration')->createFromPublicRegistration() */ public static function register($data) { - $this->application ??= Facade::getFacadeApplication(); - return $this->application->make('user/registration')->createFromPublicRegistration($data); + if (isset($this) && get_class($this) == __CLASS__) { + $app = $this->application + } else { + $app = Facade::getFacadeApplication(); + } + return $app->make('user/registration')->createFromPublicRegistration($data); } /** - * @deprecated use app()->make(\Concrete\Core\User\UserInfoRepository::class)->getByID() + * @deprecated use $app->make(\Concrete\Core\User\UserInfoRepository::class)->getByID() */ public static function getByID($uID) { - $this->application ??= Facade::getFacadeApplication(); - return $this->application->make(UserInfoRepository::class)->getByID($uID); + if (isset($this) && get_class($this) == __CLASS__) { + $app = $this->application + } else { + $app = Facade::getFacadeApplication(); + } + return $app->make(UserInfoRepository::class)->getByID($uID); } /** - * @deprecated use app()->make(\Concrete\Core\User\UserInfoRepository::class)->getByName() + * @deprecated use $app->make(\Concrete\Core\User\UserInfoRepository::class)->getByName() */ public static function getByUserName($uName) { - $this->application ??= Facade::getFacadeApplication(); - return $this->application->make(UserInfoRepository::class)->getByName($uName); + if (isset($this) && get_class($this) == __CLASS__) { + $app = $this->application + } else { + $app = Facade::getFacadeApplication(); + } + return $app->make(UserInfoRepository::class)->getByName($uName); } /** - * @deprecated use app()->make(\Concrete\Core\User\UserInfoRepository::class)->getByEmail() + * @deprecated use $app->make(\Concrete\Core\User\UserInfoRepository::class)->getByEmail() */ public static function getByEmail($uEmail) { - $this->application ??= Facade::getFacadeApplication(); - return $this->application->make(UserInfoRepository::class)->getByEmail($uEmail); + if (isset($this) && get_class($this) == __CLASS__) { + $app = $this->application + } else { + $app = Facade::getFacadeApplication(); + } + return $app->make(UserInfoRepository::class)->getByEmail($uEmail); } /** - * @deprecated use app()->make(\Concrete\Core\User\UserInfoRepository::class)->getByValidationHash() + * @deprecated use $app->make(\Concrete\Core\User\UserInfoRepository::class)->getByValidationHash() */ public static function getByValidationHash($uHash, $unredeemedHashesOnly = true) { - $this->application ??= Facade::getFacadeApplication(); - return $this->application->make(UserInfoRepository::class)->getByValidationHash($uHash, $unredeemedHashesOnly); + if (isset($this) && get_class($this) == __CLASS__) { + $app = $this->application + } else { + $app = Facade::getFacadeApplication(); + } + return $app->make(UserInfoRepository::class)->getByValidationHash($uHash, $unredeemedHashesOnly); } }