Add Profile::ensureCurrent() to verify we _certainly_ got a Profile.

This commit is contained in:
Mikael Nordfeldth 2016-02-12 13:52:48 +01:00
parent f10625f8bc
commit 5dce08d068

View 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.
*