You are here

public function Invoice::getCustomer in Commerce Invoice 8.2

Gets the customer user.

Return value

\Drupal\user\UserInterface The customer user entity. If the invoice is anonymous (customer unspecified or deleted), an anonymous user will be returned. Use $customer->isAnonymous() to check.

Overrides InvoiceInterface::getCustomer

1 call to Invoice::getCustomer()
Invoice::preSave in src/Entity/Invoice.php
Acts on an entity before the presave hook is invoked.

File

src/Entity/Invoice.php, line 150

Class

Invoice
Defines the invoice entity class.

Namespace

Drupal\commerce_invoice\Entity

Code

public function getCustomer() {
  $customer = $this
    ->get('uid')->entity;

  // Handle deleted customers.
  if (!$customer) {
    $customer = User::getAnonymousUser();
  }
  return $customer;
}