You are here

public function Shipment::getData in Commerce Shipping 8.2

Gets a shipment data value with the given key.

Used to store temporary data.

Parameters

string $key: The key.

mixed $default: The default value.

Return value

array The shipment data.

Overrides ShipmentInterface::getData

File

src/Entity/Shipment.php, line 448

Class

Shipment
Defines the shipment entity class.

Namespace

Drupal\commerce_shipping\Entity

Code

public function getData($key, $default = NULL) {
  $data = [];
  if (!$this
    ->get('data')
    ->isEmpty()) {
    $data = $this
      ->get('data')
      ->first()
      ->getValue();
  }
  return isset($data[$key]) ? $data[$key] : $default;
}