You are here

public function UcAddressesEntityController::create in Ubercart Addresses 7

Overrides EntityAPIController::create().

Creates a new address entity and makes sure it contains some default values for it.

Parameters

array $values: An array of values to set, keyed by property name.

Return value

UcAddressesAddress A new instance of the entity type.

Overrides EntityAPIController::create

File

class/uc_addresses.entity.inc, line 71
Entity integration code.

Class

UcAddressesEntityController
Ubercart Addresses entity controller class.

Code

public function create(array $values = array()) {
  if (isset($values['uid'])) {

    // If the owner is given, an new address is created for the specific user.
    $entity = UcAddressesAddressBook::get($values['uid'])
      ->addAddress();
  }
  else {

    // Else, a new unowned address is given.
    $entity = UcAddressesAddressBook::newAddress();
  }
  $entity
    ->setMultipleFields($values);
  return $entity;
}