You are here

public function UserController::singlePage in Profile 8

Builds the add/edit page for "single" profile types.

Parameters

\Drupal\user\UserInterface $user: The user account.

\Drupal\profile\Entity\ProfileTypeInterface $profile_type: The profile type.

Return value

array The response.

1 string reference to 'UserController::singlePage'
profile.routing.yml in ./profile.routing.yml
profile.routing.yml

File

src/Controller/UserController.php, line 41

Class

UserController
Provides the profile UI for users.

Namespace

Drupal\profile\Controller

Code

public function singlePage(UserInterface $user, ProfileTypeInterface $profile_type) {

  /** @var \Drupal\profile\ProfileStorageInterface $profile_storage */
  $profile_storage = $this
    ->entityTypeManager()
    ->getStorage('profile');
  $profile = $profile_storage
    ->loadByUser($user, $profile_type
    ->id());
  if ($profile) {
    return $this
      ->editForm($profile);
  }
  else {
    return $this
      ->addForm($user, $profile_type);
  }
}