You are here

function Notifications_Subscription::get_instance in Notifications 7

Same name and namespace in other branches
  1. 6.4 includes/notifications_subscription.class.inc \Notifications_Subscription::get_instance()

Get instance of this one for certain conditions

If we got multiple ones, return just the first one

Parameters

$params: Parameters to add to the subscription type to get an instance of itself

File

./notifications.subscription.inc, line 1387
Drupal Notifications Framework - Default class file

Class

Notifications_Subscription
Common base for subscription type and subscription instance

Code

function get_instance($params = array(), $return_self = FALSE) {
  $params += array(
    'type' => $this->type,
  );
  if ($user = $this
    ->get_user()) {
    $params += array(
      'uid' => $user->uid,
    );
  }
  if ($instance = $this
    ->load_single_instance($params)) {
    return $instance;
  }
  else {
    return $return_self ? $this : FALSE;
  }
}