public function AddressBook::loadAll in Commerce Core 8.2
Loads all profiles for the given customer.
Ensures that the loaded profiles are available, by filtering them against $available_countries.
Parameters
\Drupal\user\UserInterface $customer: The customer.
string $profile_type_id: The profile type ID.
array $available_countries: List of country codes. If empty, all countries will be available.
Return value
\Drupal\profile\Entity\ProfileInterface[] The available profiles, keyed by profile ID.
Overrides AddressBookInterface::loadAll
File
- modules/order/ src/ AddressBook.php, line 91 
Class
Namespace
Drupal\commerce_orderCode
public function loadAll(UserInterface $customer, $profile_type_id, array $available_countries = []) {
  if ($customer
    ->isAnonymous()) {
    return [];
  }
  $profiles = $this->profileStorage
    ->loadMultipleByUser($customer, $profile_type_id, TRUE);
  // Filter out profiles with unavailable countries.
  foreach ($profiles as $profile_id => $profile) {
    if (!$this
      ->isAvailable($profile, $available_countries)) {
      unset($profiles[$profile_id]);
    }
  }
  return $profiles;
}