public function UcAddressesAddress::__construct in Ubercart Addresses 6.2
Same name and namespace in other branches
- 7 class/UcAddressesAddress.class.php \UcAddressesAddress::__construct()
UcAddressesAddress object constructor.
@access public
Parameters
UcAddressesAddressBook $addressBook: An instance of UcAddressesAddressBook.
object $schemaAddress: Values to fill the address with.
Return value
void
Overrides UcAddressesSchemaAddress::__construct
File
- class/
UcAddressesAddress.class.php, line 66 - Contains the UcAddressesAddress class.
Class
- UcAddressesAddress
- The main address class used by uc_addresses (and extension modules).
Code
public function __construct(UcAddressesAddressBook $addressBook, $schemaAddress = NULL) {
parent::__construct($schemaAddress);
$this->addressBook = $addressBook;
if (!is_object($schemaAddress) || !$schemaAddress->aid) {
// We always need an ID.
$this
->getSchemaAddress()->aid = self::$nextNewAid--;
}
// Set other given values.
if ($schemaAddress) {
foreach ($schemaAddress as $fieldName => $value) {
$this
->privSetUcAddressField($fieldName, $value);
}
}
if ($this
->getSchemaAddress()->aid > 0) {
// If an address is just loaded, mark this instance as 'clean' (= unchanged).
$this
->clearDirty();
}
// All addresses need to be contained by an address book.
$addressBook
->addAddress($this);
}