You are here

public function InvoiceItem::unsetData in Commerce Invoice 8.2

Unsets an invoice item data value with the given key.

Parameters

string $key: The key.

Return value

$this

Overrides InvoiceItemInterface::unsetData

File

src/Entity/InvoiceItem.php, line 275

Class

InvoiceItem
Defines the invoice item entity class.

Namespace

Drupal\commerce_invoice\Entity

Code

public function unsetData($key) {
  if (!$this
    ->get('data')
    ->isEmpty()) {
    $data = $this
      ->get('data')
      ->first()
      ->getValue();
    unset($data[$key]);
    $this
      ->set('data', $data);
  }
  return $this;
}