public function AddressBookController::setDefault in Commerce Core 8.2
Sets the given profile as default.
Parameters
\Drupal\profile\Entity\ProfileInterface $profile: The profile.
Return value
\Symfony\Component\HttpFoundation\RedirectResponse A redirect back to the overview page.
1 string reference to 'AddressBookController::setDefault'
- commerce_order.routing.yml in modules/
order/ commerce_order.routing.yml - modules/order/commerce_order.routing.yml
File
- modules/
order/ src/ Controller/ AddressBookController.php, line 117
Class
- AddressBookController
- Provides the address book UI.
Namespace
Drupal\commerce_order\ControllerCode
public function setDefault(ProfileInterface $profile) {
$profile
->setDefault(TRUE);
$profile
->save();
$this
->messenger()
->addMessage($this
->t('%label is now the default address.', [
'%label' => $profile
->label(),
]));
$overview_url = Url::fromRoute('commerce_order.address_book.overview', [
'user' => $profile
->getOwnerId(),
'profile' => $profile
->id(),
]);
return new RedirectResponse($overview_url
->toString());
}