You are here

public static function Messaging_Destination::build in Messaging 6.4

Same name and namespace in other branches
  1. 7 messaging.destination.inc \Messaging_Destination::build()

Build destination with partial parameters

Parameters

$template: Object template or address type

Overrides Messaging_Object::build

2 calls to Messaging_Destination::build()
Messaging_Destination::create_type in includes/messaging_destination.class.inc
Create with parameters
Messaging_Destination::get in includes/messaging_destination.class.inc
Get from db using conditions

File

includes/messaging_destination.class.inc, line 59
Drupal Messaging Framework - Default class file

Class

Messaging_Destination
Message destination class

Code

public static function build($template) {
  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 = messaging_address_info($type, 'destination_class'))) {
    return new $class($object);
  }
  else {
    return new Messaging_Destination($object);
  }
}