Skip to content

Commit 1b33b6b

Browse files
committed
minor #13268 Update deprecated methods (Myystigri)
This PR was submitted for the 5.0 branch but it was squashed and merged into the 4.4 branch instead (closes #13268). Discussion ---------- Update deprecated methods Methods "sign" and "set" are deprecated and should not be used anymore. <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- 3c23d1d Update deprecated methods
2 parents 66b0ffc + 3c23d1d commit 1b33b6b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mercure.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ And here is the controller::
398398

399399
use Lcobucci\JWT\Builder;
400400
use Lcobucci\JWT\Signer\Hmac\Sha256;
401+
use Lcobucci\JWT\Signer\Key;
401402
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
402403
use Symfony\Component\HttpFoundation\Request;
403404
use Symfony\Component\HttpFoundation\Response;
@@ -413,9 +414,8 @@ And here is the controller::
413414
$username = $this->getUser()->getUsername(); // Retrieve the username of the current user
414415
$token = (new Builder())
415416
// set other appropriate JWT claims, such as an expiration date
416-
->set('mercure', ['subscribe' => ["http://example.com/user/$username"]]) // could also include the security roles, or anything else
417-
->sign(new Sha256(), $this->getParameter('mercure_secret_key')) // don't forget to set this parameter! Test value: aVerySecretKey
418-
->getToken();
417+
->withClaim('mercure', ['subscribe' => ["http://example.com/user/$username"]]) // could also include the security roles, or anything else
418+
->getToken(new Sha256(), new Key($this->getParameter('mercure_secret_key'))); // don't forget to set this parameter! Test value: aVerySecretKey
419419

420420
$response = $this->json(['@id' => '/demo/books/1', 'availability' => 'https://schema.org/InStock']);
421421
$response->headers->set(

0 commit comments

Comments
 (0)