Skip to content

Commit 2d9c782

Browse files
committed
Merge branch '5.0'
* 5.0: Update multiple services example Update messenger.rst Fixed CoverageListener usage with custom SUT solver
2 parents f831002 + 98cacec commit 2d9c782

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

components/messenger.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ Concepts
5858
both when a message is originally dispatched and again later when a message
5959
is received from a transport,
6060

61-
**Envelope**
61+
**Envelope**:
6262
Messenger specific concept, it gives full flexibility inside the message bus,
6363
by wrapping the messages into it, allowing to add useful information inside
6464
through *envelope stamps*.
6565

66-
**Envelope Stamps**
66+
**Envelope Stamps**:
6767
Piece of information you need to attach to your message: serializer context
6868
to use for transport, markers identifying a received message or any sort of
6969
metadata your middleware or transport layer may use.

components/phpunit_bridge.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ your application, you can use your own SUT (System Under Test) solver:
936936
</listeners>
937937
938938
The ``My\Namespace\SutSolver::solve`` can be any PHP callable and receives the
939-
current test classname as its first argument.
939+
current test as its first argument.
940940

941941
Finally, the listener can also display warning messages when the SUT solver does
942942
not find the SUT:

service_container.rst

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,15 @@ made. To do that, you create a new class::
295295
namespace App\Updates;
296296

297297
use App\Service\MessageGenerator;
298+
use Symfony\Component\Mailer\MailerInterface;
299+
use Symfony\Component\Mime\Email;
298300

299301
class SiteUpdateManager
300302
{
301303
private $messageGenerator;
302304
private $mailer;
303305

304-
public function __construct(MessageGenerator $messageGenerator, \Swift_Mailer $mailer)
306+
public function __construct(MessageGenerator $messageGenerator, MailerInterface $mailer)
305307
{
306308
$this->messageGenerator = $messageGenerator;
307309
$this->mailer = $mailer;
@@ -311,19 +313,21 @@ made. To do that, you create a new class::
311313
{
312314
$happyMessage = $this->messageGenerator->getHappyMessage();
313315

314-
$message = (new \Swift_Message('Site update just happened!'))
315-
->setFrom('[email protected]')
316-
->setTo('[email protected]')
317-
->addPart(
318-
'Someone just updated the site. We told them: '.$happyMessage
319-
);
316+
$email = (new Email())
317+
318+
319+
->subject('Site update just happened!')
320+
->text('Someone just updated the site. We told them: '.$happyMessage);
320321

321-
return $this->mailer->send($message) > 0;
322+
$this->mailer->send($email);
323+
324+
// ...
322325
}
323326
}
324327

325-
This needs the ``MessageGenerator`` *and* the ``Swift_Mailer`` service. That's no
326-
problem! In fact, this new service is ready to be used. In a controller, for example,
328+
This needs the ``MessageGenerator`` *and* the ``Mailer`` service. That's no
329+
problem, we ask them by type hinting their class and interface names!
330+
Now, this new service is ready to be used. In a controller, for example,
327331
you can type-hint the new ``SiteUpdateManager`` class and use it::
328332

329333
// src/Controller/SiteController.php

0 commit comments

Comments
 (0)