]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Add Profile::ensureCurrent() to verify we _certainly_ got a Profile.
authorMikael Nordfeldth <mmn@hethane.se>
Fri, 12 Feb 2016 12:52:48 +0000 (13:52 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Fri, 12 Feb 2016 12:52:48 +0000 (13:52 +0100)
classes/Profile.php

index 875ad9ade1bd31851c60394c83e9c985d054d249..e4ab508c0616c6d802a9cc541c9005391f0562ed 100644 (file)
@@ -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.
      *