You are here

public static function Notifications_Subscription::build in Notifications 6.4

Build for a subscription type

Parameters

$template: Template object or subscription type

Overrides Messaging_Object::build

4 calls to Notifications_Subscription::build()
notifications_anonymous_page_subscribe in notifications_anonymous/notifications_anonymous.pages.inc
Menu callback add subscription
notifications_build_subscription in ./notifications.module
Build subscription object properly
Notifications_Custom_Subscription::build in notifications_custom/notifications_custom.class.inc
Build for a subscription type
notifications_load_subscription in ./notifications.module
Get an individual subscription.
1 method overrides Notifications_Subscription::build()
Notifications_Custom_Subscription::build in notifications_custom/notifications_custom.class.inc
Build for a subscription type

File

includes/notifications_subscription.class.inc, line 111
Drupal Notifications Framework - Default class file

Class

Notifications_Subscription
Message destination class

Code

public static function build($template, $default_class = 'Notifications_Subscription') {
  if (is_array($template)) {
    $type = NULL;
    $template = (object) $template;
  }
  if (is_object($template)) {
    $object = $template;
    $type = $template->type;
  }
  else {
    $type = $template;
    $object = array(
      'type' => $type,
    );
  }

  // The type may define its own class
  if ($type && ($class = notifications_subscription_types($type, 'class'))) {
    return new $class($object);
  }
  else {
    return new $default_class($object);
  }
}