Skip to content

Commit 3b6003e

Browse files
committed
Merge branch 'mercure' of github.com:dunglas/symfony-docs into mercure
2 parents b338926 + 80807a6 commit 3b6003e

File tree

1 file changed

+13
-27
lines changed

1 file changed

+13
-27
lines changed

mercure.rst

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Run the following command to start it:
8888
Configuration
8989
-------------
9090

91-
The preferred way to configure the Mercure Bundle is using
91+
The preferred way to configure the MercureBundle is using
9292
:doc:`environment variables </configuration>`.
9393

9494
Set the URL of your hub as the value of the ``MERCURE_PUBLISH_URL`` env var.
@@ -127,7 +127,7 @@ public updates (see the authorization_ section for further informations).
127127
.. caution::
128128

129129
Don't put the secret key in ``MERCURE_JWT_SECRET``, it will not work!
130-
This env var must contain a JWT, signed with the secret key.
130+
This environment variable must contain a JWT, signed with the secret key.
131131

132132
Also, be sure to keep both the secret key and the JWTs... secrets!
133133

@@ -143,9 +143,7 @@ updates to the Hub.
143143

144144
The ``Publisher`` service can be injected using the
145145
:doc:`autowiring </service_container/autowiring>` in any other
146-
service, including controllers:
147-
148-
.. code-block:: php
146+
service, including controllers::
149147

150148
// src/Controller/PublishController.php
151149
namespace App\Controller;
@@ -176,7 +174,7 @@ the **topic** being updated. This topic should be an IRI_
176174
of the resource being dispatched.
177175

178176
Usually, this parameter contains the original URL of the resource
179-
transmitted to the client, but it can be any valid IRI, it doesn't
177+
transmitted to the client, but it can be any valid IRI_, it doesn't
180178
have to be an URL that exists (similarly to XML namespaces).
181179

182180
The second parameter of the constructor is the content of the update.
@@ -245,9 +243,7 @@ and to configure properly a transport (if you don't, the handler will
245243
be called synchronously).
246244

247245
Then, dispatch the Mercure ``Update`` to the Messenger's Message Bus,
248-
it will be handled automatically:
249-
250-
.. code-block:: php
246+
it will be handled automatically::
251247

252248
// src/Controller/PublishController.php
253249
namespace App\Controller;
@@ -281,11 +277,8 @@ in a ``Link`` HTTP header.
281277

282278
.. image:: /_images/mercure/discovery.png
283279

284-
Symfony makes it easy to create ``Link`` headers thanks to
285-
:doc:`WebLink Component </web_link>`.
286-
Install it, then use it through the ``AbstractController::addLink`` helper method:
287-
288-
.. code-block:: php
280+
You can create ``Link`` headers with the :doc:`WebLink Component </web_link>`,
281+
by using the ``AbstractController::addLink`` helper method::
289282

290283
// src/Controller/DiscoverController.php
291284
namespace App\Controller;
@@ -299,7 +292,8 @@ Install it, then use it through the ``AbstractController::addLink`` helper metho
299292
{
300293
public function __invoke(Request $request): JsonResponse
301294
{
302-
$hubUrl = $this->getParameter('mercure.default_hub'); // This parameter is automatically created by the MercureBundle
295+
// This parameter is automatically created by the MercureBundle
296+
$hubUrl = $this->getParameter('mercure.default_hub');
303297

304298
// Link: <http://localhost:3000/hub>; rel="mercure"
305299
$this->addLink($request, new Link('mercure', $hubUrl));
@@ -338,9 +332,7 @@ Authorization
338332

339333
Mercure also allows to dispatch updates only to authorized clients.
340334
To do so, set the list of **targets** allowed to receive the update
341-
as the third parameter of the ``Update`` constructor:
342-
343-
.. code-block:: php
335+
as the third parameter of the ``Update`` constructor::
344336

345337
// src/Controller/Publish.php
346338
namespace App\Controller;
@@ -388,9 +380,7 @@ To generate the JWT, we'll use the ``lcobucci/jwt`` library. Install it:
388380
389381
$ composer require lcobucci/jwt
390382
391-
And here is the controller:
392-
393-
.. code-block:: php
383+
And here is the controller::
394384

395385
// src/Controller/DiscoverController.php
396386
namespace App\Controller;
@@ -436,9 +426,7 @@ Generating Programmatically The JWT Used to Publish
436426

437427
Instead of directly storing a JWT in the configuration,
438428
you can create a service that will return the token used by
439-
the ``Publisher`` object.
440-
441-
.. code-block:: php
429+
the ``Publisher`` object::
442430

443431
// src/Mercure/MyJwtProvider.php
444432
namespace App\Mercure;
@@ -510,9 +498,7 @@ Start by installing the library using its official recipe:
510498
$ composer require api
511499
512500
Then, creating the following entity is enough to get a fully-featured
513-
hypermedia API, and automatic update broadcasting through the Mercure hub:
514-
515-
.. code-block:: php
501+
hypermedia API, and automatic update broadcasting through the Mercure hub::
516502

517503
// src/Entity/Book.php
518504
namespace App\Entity;

0 commit comments

Comments
 (0)