You are here

public function UcAddressesSchemaAddress::setMultipleFields in Ubercart Addresses 7

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

Set multiple fields at once.

@access public

Parameters

array $fields: An array of fields with $fieldName => $value.

boolean $fieldsMustExist: (optional) If TRUE, every field in the array must exists. If there are fields in the array that do not exists an UcAddressInvalidFieldException will be thrown. Defaults to FALSE (no exceptions will be thrown).

Return value

void

Throws

UcAddressInvalidFieldException

File

class/UcAddressesSchemaAddress.class.php, line 308
Contains the UcAddressesSchemaAddress class.

Class

UcAddressesSchemaAddress
The schema address class.

Code

public function setMultipleFields($fields, $fieldsMustExist = FALSE) {
  foreach ($fields as $fieldName => $value) {
    if (!$fieldsMustExist && !self::fieldExists($fieldName)) {
      continue;
    }
    $this
      ->setField($fieldName, $value);
  }
}