You are here

public function ProfileController::setDefault in Profile 8

Mark profile as default.

Parameters

\Drupal\profile\Entity\ProfileInterface $profile: The profile.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse A redirect back to the profile listing.

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

File

src/Controller/ProfileController.php, line 20

Class

ProfileController

Namespace

Drupal\profile\Controller

Code

public function setDefault(ProfileInterface $profile) {
  $profile
    ->setDefault(TRUE);
  $profile
    ->save();
  $this
    ->messenger()
    ->addMessage($this
    ->t('The %label profile has been marked as default.', [
    '%label' => $profile
      ->label(),
  ]));
  return new RedirectResponse($profile
    ->toUrl('collection')
    ->toString());
}