public function getProfile(UserInterface $entity) {
    $user_profile = NULL;

    /** @var \Drupal\profile\ProfileStorageInterface $storage */
    try {
      $storage = $this->entityTypeManager->getStorage('profile');
      if (!empty($storage)) {
        $user_profile = $storage->loadByUser($entity, 'profile', TRUE);

        // TODO: Remove once #3005113 is fixed in the profile module.
        if ($user_profile === FALSE) {
          $user_profile = NULL;
        }
      }
    }
    catch (\Exception $e) {
    }
    return $user_profile;
  }
public function getProfile(UserInterface $entity) {
    $user_profile = NULL;

    /** @var \Drupal\profile\ProfileStorageInterface $storage */
    try {
      $storage = $this->entityTypeManager->getStorage('profile');
      if (!empty($storage)) {
        $user_profile = $storage->loadByUser($entity, 'profile', TRUE);

        // TODO: Remove once #3005113 is fixed in the profile module.
        if ($user_profile === FALSE) {
          $user_profile = NULL;
        }
      }
    }
    catch (\Exception $e) {
    }
    return $user_profile;
  }
public function getProfile ( UserInterface $ entity ) { $ user_profile = NULL ; /** @var \Drupal\profile\ProfileStorageInterface $storage */ try { $ storage = $ this -> entityTypeManager -> getStorage ( 'profile' ) ; if ( ! empty ( $ storage ) ) { $ user_profile = $ storage -> loadByUser ( $ entity , 'profile' , TRUE ) ; // TODO: Remove once #3005113 is fixed in the profile module. if ( $ user_profile === FALSE ) { $ user_profile = NULL ; } } } catch ( \ Exception $ e ) { } return $ user_profile ; }
Get the Profile entity.

@param \Drupal\user\UserInterface $entity
The user entity to get the profile from.

@return \Drupal\profile\Entity\ProfileInterface|null
Returns the Profile or NULL if profile does not exist.
Get the Profile entity .