You are here

private static function UCXF_FieldList::dbResultToField in Extra Fields Checkout Pane 7

Same name and namespace in other branches
  1. 6.2 class/UCXF_FieldList.class.php \UCXF_FieldList::dbResultToField()

Creates UCXF_Field objects from a database resource.

@access private @static

Parameters

resource $result: Database result

Return value

void

3 calls to UCXF_FieldList::dbResultToField()
UCXF_FieldList::loadAll in class/UCXF_FieldList.class.php
Loads all fields @access private @static
UCXF_FieldList::loadAllFromPane in class/UCXF_FieldList.class.php
Loads all fields from a specific pane type
UCXF_FieldList::loadOne in class/UCXF_FieldList.class.php
Load a single field if not already loaded

File

class/UCXF_FieldList.class.php, line 327
Contains the UCXF_FieldList class.

Class

UCXF_FieldList
This class is used to keep track of all loaded fields in one request. It's also used as a central place to request fields.

Code

private static function dbResultToField($result) {
  $weights = variable_get('uc_address_fields_weight', array());

  // Create each UCXF_Field object from the database record.
  while ($field_data = $result
    ->fetch()) {

    // Skip fields that have already been loaded (and perhaps modified).
    if (!isset(self::$fields[$field_data->field_id])) {
      $field = self::createField($field_data->pane_type);

      // Populate field information.
      $field
        ->from_array($field_data);

      // Apply weight setting for address fields.
      if ($field instanceof UCXF_AddressField && isset($weights[$field->db_name])) {
        $field->weight = $weights[$field->db_name];
      }

      // Add field to array.
      self::$fields[$field->field_id] = $field;

      // Give other modules to react on this.
      module_invoke_all('ucxf_field', $field, 'load');
    }
  }
}