@@ -740,17 +740,16 @@ Then, configure this service ID as the ``success_handler``:
740
740
],
741
741
]);
742
742
743
- Customize generated Login Link
744
- ------------------------------
743
+ Customizing the Login Link
744
+ --------------------------
745
745
746
746
.. versionadded :: 5.3
747
747
748
748
The possibility to customize the login link was introduced in Symfony 5.3.
749
749
750
- In some use cases it may be useful to customize the Login Link. In addition
751
- to the ``UserInterface ``, it is therefore possible to pass a ``Request `` to the ``createLoginLink ``
752
- method. In this example, our route is localized with the user locale which may
753
- be different from the current locale::
750
+ The ``createLoginLink() `` method accepts a second optional argument to pass the
751
+ ``Request `` object used when generating the login link. This allows to customize
752
+ features such as the locale used to generate the link::
754
753
755
754
// src/Controller/SecurityController.php
756
755
namespace App\Controller;
@@ -774,8 +773,7 @@ be different from the current locale::
774
773
$userRequest = clone $request;
775
774
$userRequest->setLocale($user->getLocale() ?? $request->getDefaultLocale());
776
775
777
- // create a login link for $user this returns an instance
778
- // of LoginLinkDetails
776
+ // create a login link for $user (this returns an instance of LoginLinkDetails)
779
777
$loginLinkDetails = $loginLinkHandler->createLoginLink($user, $userRequest);
780
778
$loginLink = $loginLinkDetails->getUrl();
781
779
0 commit comments