From 5dce08d068b13353ad7bb4de339f4a4996710aff Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Fri, 12 Feb 2016 13:52:48 +0100 Subject: [PATCH] Add Profile::ensureCurrent() to verify we _certainly_ got a Profile. --- classes/Profile.php | 9 +++++++++ 1 file changed, 9 insertions(+) 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. * -- 2.39.5