From: Mikael Nordfeldth Date: Fri, 12 Feb 2016 12:52:48 +0000 (+0100) Subject: Add Profile::ensureCurrent() to verify we _certainly_ got a Profile. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5dce08d068b13353ad7bb4de339f4a4996710aff;p=quix0rs-gnu-social.git Add Profile::ensureCurrent() to verify we _certainly_ got a Profile. --- diff --git a/classes/Profile.php b/classes/Profile.php index 875ad9ade1..e4ab508c06 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -1628,6 +1628,15 @@ class Profile extends Managed_DataObject return $profile; } + static function ensureCurrent() + { + $profile = self::current(); + if (!$profile instanceof Profile) { + throw new AuthorizationException('A currently scoped profile is required.'); + } + return $profile; + } + /** * Magic function called at serialize() time. *