Skip to content

Commit 3f34d3a

Browse files
committed
Merge branch '4.2'
* 4.2: add blank line before directive restructure paragraphs about sender and receiver fix indention
2 parents 882423c + 041c879 commit 3f34d3a

File tree

4 files changed

+56
-56
lines changed

4 files changed

+56
-56
lines changed

components/messenger.rst

Lines changed: 53 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ that will do the required processing for your message::
111111

112112
class MyMessageHandler
113113
{
114-
public function __invoke(MyMessage $message)
115-
{
116-
// Message processing...
117-
}
114+
public function __invoke(MyMessage $message)
115+
{
116+
// Message processing...
117+
}
118118
}
119119

120120
Adding Metadata to Messages (Envelopes)
@@ -199,13 +199,12 @@ transport will be responsible for communicating with your message broker or 3rd
199199
Your own Sender
200200
~~~~~~~~~~~~~~~
201201

202-
Using the :class:`Symfony\\Component\\Messenger\\Transport\\Sender\\SenderInterface`,
203-
you can create your own message sender.
204202
Imagine that you already have an ``ImportantAction`` message going through the
205203
message bus and being handled by a handler. Now, you also want to send this
206204
message as an email.
207205

208-
First, create your sender::
206+
Using the :class:`Symfony\\Component\\Messenger\\Transport\\Sender\\SenderInterface`,
207+
you can create your own message sender::
209208

210209
namespace App\MessageSender;
211210

@@ -215,34 +214,34 @@ First, create your sender::
215214

216215
class ImportantActionToEmailSender implements SenderInterface
217216
{
218-
private $mailer;
219-
private $toEmail;
220-
221-
public function __construct(\Swift_Mailer $mailer, string $toEmail)
222-
{
223-
$this->mailer = $mailer;
224-
$this->toEmail = $toEmail;
225-
}
226-
227-
public function send(Envelope $envelope): Envelope
228-
{
229-
$message = $envelope->getMessage();
230-
231-
if (!$message instanceof ImportantAction) {
232-
throw new \InvalidArgumentException(sprintf('This transport only supports "%s" messages.', ImportantAction::class));
233-
}
234-
235-
$this->mailer->send(
236-
(new \Swift_Message('Important action made'))
237-
->setTo($this->toEmail)
238-
->setBody(
239-
'<h1>Important action</h1><p>Made by '.$message->getUsername().'</p>',
240-
'text/html'
241-
)
242-
);
243-
244-
return $envelope;
245-
}
217+
private $mailer;
218+
private $toEmail;
219+
220+
public function __construct(\Swift_Mailer $mailer, string $toEmail)
221+
{
222+
$this->mailer = $mailer;
223+
$this->toEmail = $toEmail;
224+
}
225+
226+
public function send(Envelope $envelope): Envelope
227+
{
228+
$message = $envelope->getMessage();
229+
230+
if (!$message instanceof ImportantAction) {
231+
throw new \InvalidArgumentException(sprintf('This transport only supports "%s" messages.', ImportantAction::class));
232+
}
233+
234+
$this->mailer->send(
235+
(new \Swift_Message('Important action made'))
236+
->setTo($this->toEmail)
237+
->setBody(
238+
'<h1>Important action</h1><p>Made by '.$message->getUsername().'</p>',
239+
'text/html'
240+
)
241+
);
242+
243+
return $envelope;
244+
}
246245
}
247246

248247
Your own Receiver
@@ -257,9 +256,7 @@ application but you can't use an API and need to use a shared CSV file with new
257256
orders.
258257

259258
You will read this CSV file and dispatch a ``NewOrder`` message. All you need to
260-
do is to write your custom CSV receiver and Symfony will do the rest.
261-
262-
First, create your receiver::
259+
do is to write your own CSV receiver::
263260

264261
namespace App\MessageReceiver;
265262

@@ -270,30 +267,30 @@ First, create your receiver::
270267

271268
class NewOrdersFromCsvFileReceiver implements ReceiverInterface
272269
{
273-
private $serializer;
274-
private $filePath;
270+
private $serializer;
271+
private $filePath;
275272

276-
public function __construct(SerializerInterface $serializer, string $filePath)
277-
{
273+
public function __construct(SerializerInterface $serializer, string $filePath)
274+
{
278275
$this->serializer = $serializer;
279276
$this->filePath = $filePath;
280-
}
277+
}
281278

282-
public function receive(callable $handler): void
283-
{
284-
$ordersFromCsv = $this->serializer->deserialize(file_get_contents($this->filePath), 'csv');
279+
public function receive(callable $handler): void
280+
{
281+
$ordersFromCsv = $this->serializer->deserialize(file_get_contents($this->filePath), 'csv');
285282

286-
foreach ($ordersFromCsv as $orderFromCsv) {
287-
$order = new NewOrder($orderFromCsv['id'], $orderFromCsv['account_id'], $orderFromCsv['amount']);
283+
foreach ($ordersFromCsv as $orderFromCsv) {
284+
$order = new NewOrder($orderFromCsv['id'], $orderFromCsv['account_id'], $orderFromCsv['amount']);
288285

289-
$handler(new Envelope($order));
290-
}
291-
}
286+
$handler(new Envelope($order));
287+
}
288+
}
292289

293-
public function stop(): void
294-
{
295-
// noop
296-
}
290+
public function stop(): void
291+
{
292+
// noop
293+
}
297294
}
298295

299296
Receiver and Sender on the same Bus
@@ -306,6 +303,7 @@ middleware will know it should not route these messages again to a transport.
306303

307304
Learn more
308305
----------
306+
309307
.. toctree::
310308
:maxdepth: 1
311309
:glob:

messenger.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ will give you access to the following services:
827827

828828
Learn more
829829
----------
830+
830831
.. toctree::
831832
:maxdepth: 1
832833
:glob:

testing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ Use the ``submitForm()`` method to submit the form that contains the given butto
733733
$client->request('GET', '/post/hello-world');
734734

735735
$crawler = $client->submitForm('Add comment', [
736-
'comment_form[content]' => '...',
736+
'comment_form[content]' => '...',
737737
]);
738738

739739
The first argument of ``submitForm()`` is the text content, ``id``, ``value`` or

workflow.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ requires:
533533
metadata:
534534
priority: 0.5
535535
# ...
536+
536537
.. code-block:: xml
537538
538539
<!-- config/packages/workflow.xml -->

0 commit comments

Comments
 (0)