You are here

public static function Notifications_Subscription::normalize_fields in Notifications 6.4

Convert fields to a standard format: arrray of object fields

3 calls to Notifications_Subscription::normalize_fields()
Notifications_Subscription::add_fields in includes/notifications_subscription.class.inc
Add field values to existing ones
Notifications_Subscription::get_type_fields in includes/notifications_subscription.class.inc
Get fields from subscription type as normalized array of objects
Notifications_Subscription::__set in includes/notifications_subscription.class.inc
Magic method, set protected properties

File

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

Class

Notifications_Subscription
Message destination class

Code

public static function normalize_fields($fields) {
  $normal = array();
  if ($fields && is_array($fields)) {
    foreach ($fields as $key => $value) {
      if (is_object($value)) {
        $normal[] = $value;
      }
      elseif (is_array($value)) {

        // Object or Array with type, value keys
        $normal[] = self::build_field($value['type'], $value['value']);
      }
      elseif (is_numeric($key) && is_string($value)) {

        // In this case the value is the field type
        $normal[] = self::build_field($value, NULL);
      }
      else {

        // Default, key should be field type, value may be NULL
        $normal[] = self::build_field($key, $value);
      }
    }
  }
  return $normal;
}