Skip to content

Commit 309443c

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: Update deprecated methods
2 parents 3097cc9 + 1b33b6b commit 309443c

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)