public function UcAddressesAddress::setField in Ubercart Addresses 7
Same name and namespace in other branches
- 6.2 class/UcAddressesAddress.class.php \UcAddressesAddress::setField()
Override of UcAddressesSchemaAddress::setField().
Prevents setting some schema fields directly.
@access public
Parameters
string $fieldName: The name of the field whose value we will set.
mixed $value: The value to which to set the field.
Return value
void
Throws
UcAddressInvalidFieldException
Overrides UcAddressesSchemaAddress::setField
File
- class/
UcAddressesAddress.class.php, line 324 - Contains the UcAddressesAddress class.
Class
- UcAddressesAddress
- The main address class used by uc_addresses (and extension modules).
Code
public function setField($fieldName, $value) {
switch ($fieldName) {
case 'aid':
// Don't set.
// @todo Throw an Exception here?
break;
case 'uid':
// Only set if the address is unowned. Else, ignore it.
// @todo Throw an Exception here?
if (!$this
->isOwned()) {
$this
->setOwner($value);
}
break;
case 'address_name':
$this
->setName($value);
break;
case 'default_shipping':
if ($value) {
$this
->setAsDefault('shipping');
}
break;
case 'default_billing':
if ($value) {
$this
->setAsDefault('billing');
}
break;
default:
parent::setField($fieldName, $value);
break;
}
}