You are here

public function ProfileController::addProfile in Profile 2 8

Provides the profile submission form.

Parameters

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

\Drupal\profile\ProfileTypeInterface $profile_type: The profile type entity for the profile.

Return value

array A profile submission form.

1 string reference to 'ProfileController::addProfile'
profile.routing.yml in ./profile.routing.yml
profile.routing.yml

File

src/Controller/ProfileController.php, line 32
Contains \Drupal\profile\Controller\ProfileController.

Class

ProfileController
Returns responses for ProfileController routes.

Namespace

Drupal\profile\Controller

Code

public function addProfile(UserInterface $user, ProfileTypeInterface $profile_type) {
  $profile = $this
    ->entityManager()
    ->getStorage('profile')
    ->create(array(
    'uid' => $user
      ->id(),
    'type' => $profile_type
      ->id(),
  ));
  return $this
    ->entityFormBuilder()
    ->getForm($profile, 'add', array(
    'uid' => $user
      ->id(),
    'created' => REQUEST_TIME,
  ));
}