We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit b67a611c authored by mattl's avatar mattl

Allow default data from Profile_prefs::getData call

parent 933bf0b0
...@@ -112,8 +112,17 @@ class Profile_prefs extends Managed_DataObject ...@@ -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;
} }
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