Subscription class gets exception throwing getSubscription function
This commit is contained in:
parent
901a825b61
commit
61aa71ed34
@ -232,9 +232,25 @@ class Subscription extends Managed_DataObject
|
|||||||
|
|
||||||
static function exists(Profile $subscriber, Profile $other)
|
static function exists(Profile $subscriber, Profile $other)
|
||||||
{
|
{
|
||||||
$sub = Subscription::pkeyGet(array('subscriber' => $subscriber->id,
|
try {
|
||||||
'subscribed' => $other->id));
|
$sub = self::getSubscription($subscriber, $other);
|
||||||
return ($sub instanceof Subscription);
|
} catch (NoResultException $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function getSubscription(Profile $subscriber, Profile $other)
|
||||||
|
{
|
||||||
|
// This is essentially a pkeyGet but we have an object to return in NoResultException
|
||||||
|
$sub = new Subscription();
|
||||||
|
$sub->subscriber = $subscriber->id;
|
||||||
|
$sub->subscribed = $other->id;
|
||||||
|
if (!$sub->find(true)) {
|
||||||
|
throw new NoResultException($sub);
|
||||||
|
}
|
||||||
|
return $sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
function asActivity()
|
function asActivity()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user