You are here

public function Invoice::getData in Commerce Invoice 8.2

Gets an invoice data value with the given key.

Used to store temporary data.

Parameters

string $key: The key.

mixed $default: The default value.

Return value

mixed The value.

Overrides InvoiceInterface::getData

File

src/Entity/Invoice.php, line 478

Class

Invoice
Defines the invoice entity class.

Namespace

Drupal\commerce_invoice\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;
}