You are here

public function ProfileStorage::loadDefaultByUser in Profile 8

Loads the given user's default profile.

Parameters

\Drupal\Core\Session\AccountInterface $account: The user.

string $profile_type_id: The profile type ID.

Return value

\Drupal\profile\Entity\ProfileInterface|null The profile. NULL if no matching entity was found.

Overrides ProfileStorageInterface::loadDefaultByUser

Deprecated

in Profile 1.0. Use loadByUser() instead.

File

src/ProfileStorage.php, line 51

Class

ProfileStorage
Defines the entity storage for profile.

Namespace

Drupal\profile

Code

public function loadDefaultByUser(AccountInterface $account, $profile_type_id) {
  $result = $this
    ->loadByProperties([
    'uid' => $account
      ->id(),
    'type' => $profile_type_id,
    'status' => TRUE,
    'is_default' => TRUE,
  ]);
  return !empty($result) ? reset($result) : NULL;
}