#[Route(path: '/account/address/default-{type}/{addressId}', name: 'frontend.account.address.set-default-address', defaults: ['_loginRequired' => true], methods: ['POST'])]
public function switchDefaultAddress(string
$type, string
$addressId, SalesChannelContext
$context, CustomerEntity
$customer): RedirectResponse
{ if (!Uuid::
isValid($addressId)) { throw new InvalidUuidException($addressId);
} $success = true;
try { if ($type === self::ADDRESS_TYPE_SHIPPING
) { $this->accountService->
setDefaultShippingAddress($addressId,
$context,
$customer);
} elseif ($type === self::ADDRESS_TYPE_BILLING
) { $this->accountService->
setDefaultBillingAddress($addressId,
$context,
$customer);
} else { $success = false;
} } catch (AddressNotFoundException
) { $success = false;
} return new RedirectResponse( $this->
generateUrl('frontend.account.address.page',
['changedDefaultAddress' =>
$success]) );