You are here

private function UcAddressesAddressBook::dbResultToAddresses in Ubercart Addresses 7

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

Creates UcAddressesAddress objects from a database resource.

@access private

Parameters

resource $result: Database result.

Return value

void

3 calls to UcAddressesAddressBook::dbResultToAddresses()
UcAddressesAddressBook::loadAll in class/UcAddressesAddressBook.class.php
Loads all addresses from database when they not already loaded.
UcAddressesAddressBook::loadDefaults in class/UcAddressesAddressBook.class.php
Loads all addresses from database when they not already loaded.
UcAddressesAddressBook::loadOne in class/UcAddressesAddressBook.class.php
Loads a single address from the database if not already loaded.

File

class/UcAddressesAddressBook.class.php, line 974
Contains the UcAddressesAddressBook class.

Class

UcAddressesAddressBook
The address book class

Code

private function dbResultToAddresses($result) {

  // Create each UcAddressesAddress object from the database record.
  $loaded_addresses = array();
  foreach ($result as $obj) {

    // Skip addresses that have already been loaded (and perhaps modified).
    if (!isset($this->addresses[$obj->aid])) {
      $address = new UcAddressesAddress($this, $obj);
      if ($address
        ->isDefault('shipping')) {
        $this->defaultAddresses['shipping'] = $address;
      }
      if ($address
        ->isDefault('billing')) {
        $this->defaultAddresses['billing'] = $address;
      }

      // Give other modules a chance to add their fields.
      module_invoke_all('uc_addresses_address_load', $address, $obj);
      $loaded_addresses[$obj->aid] = $address;
    }
  }
  if (count($loaded_addresses) > 0) {

    // Invoke entity load hook.
    entity_get_controller('uc_addresses')
      ->invokeLoad($loaded_addresses);
  }
}