Commit b67a611c authored by mmn's avatar mmn

Allow default data from Profile_prefs::getData call

parent 933bf0b0
......@@ -112,8 +112,17 @@ class Profile_prefs extends Managed_DataObject
return $pref;
}
static function getData(Profile $profile, $namespace, $topic) {
$pref = self::getTopic($profile, $namespace, $topic);
static function getData(Profile $profile, $namespace, $topic, $def=null) {
try {
$pref = self::getTopic($profile, $namespace, $topic);
} catch (NoResultException $e) {
if ($def === null) {
// If no default value was set, continue the exception.
throw $e;
}
// If there was a default value, return that.
return $def;
}
return $pref->data;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment