function Notifications_Subscription::get_instance in Notifications 6.4
Same name and namespace in other branches
- 7 notifications.subscription.inc \Notifications_Subscription::get_instance()
Get instance of this one for certain conditions
Parameters
$params: Parameters to add to the subscription type to get an instance of itself
$return_self: Return itself if no instance found
File
- includes/
notifications_subscription.class.inc, line 746 - Drupal Notifications Framework - Default class file
Class
- Notifications_Subscription
- Message destination class
Code
function get_instance($params = array(), $return_self = FALSE) {
$params += array(
'type' => $this->type,
);
$cache =& messaging_static('Notifications_Subscription_instances');
$cache_key = notifications_array_serialize($params);
if (!isset($cache[$cache_key])) {
$subs = notifications_get_subscriptions($params);
$cache[$cache_key] = $subs ? current($subs) : FALSE;
}
return $cache[$cache_key] ? $cache[$cache_key] : ($return_self ? $this : NULL);
}