You are here

public function AddressBook::hasUi in Commerce Core 8.2

Gets whether the address book has a UI exposed.

Usually presented as an "Address book" tab on user pages, replacing profile module's per-profile-type tabs.

Return value

bool TRUE if the address book has a UI exposed, FALSE otherwise.

Overrides AddressBookInterface::hasUi

File

modules/order/src/AddressBook.php, line 59

Class

AddressBook

Namespace

Drupal\commerce_order

Code

public function hasUi() {
  $profile_types = $this
    ->loadTypes();
  if (empty($profile_types)) {

    // No profile types available.
    return FALSE;
  }
  elseif (count($profile_types) === 1) {
    $profile_type = reset($profile_types);
    if (!$profile_type
      ->allowsMultiple()) {

      // There is only one profile type, and it only allows one profile per
      // customer. No point in presenting an "address book" for one address.
      return FALSE;
    }
  }
  return TRUE;
}