Allow default data from Profile_prefs::getData call
This commit is contained in:
parent
933bf0b026
commit
b67a611ca7
|
@ -112,8 +112,17 @@ class Profile_prefs extends Managed_DataObject
|
||||||
return $pref;
|
return $pref;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getData(Profile $profile, $namespace, $topic) {
|
static function getData(Profile $profile, $namespace, $topic, $def=null) {
|
||||||
|
try {
|
||||||
$pref = self::getTopic($profile, $namespace, $topic);
|
$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;
|
return $pref->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user