You are here

protected function ShipmentController::getAddress in Ubercart 8.4

Returns an address from an object.

Parameters

\Drupal\uc_fulfillment\ShipmentInterface $uc_shipment: A Shipment object.

string $type: The key prefix to use to extract the address.

Return value

\Drupal\uc_store\AddressInterface An address object.

File

shipping/uc_fulfillment/src/Controller/ShipmentController.php, line 349

Class

ShipmentController
Controller routines for shipments.

Namespace

Drupal\uc_fulfillment\Controller

Code

protected function getAddress(ShipmentInterface $uc_shipment, $type) {
  $name = $shipment->{$type . '_first_name'} . ' ' . $shipment->{$type . '_last_name'};
  $address = Address::create();
  $address
    ->setFirstName($shipment->{$type . '_first_name'})
    ->setLastName($shipment->{$type . '_last_name'})
    ->setCompany($shipment->{$type . '_company'})
    ->setStreet1($shipment->{$type . '_street1'})
    ->setStreet2($shipment->{$type . '_street2'})
    ->setCity($shipment->{$type . '_city'})
    ->setZone($shipment->{$type . '_zone'})
    ->setPostalCode($shipment->{$type . '_postal_code'})
    ->setCountry($shipment->{$type . '_country'});
  return $address;
}