diff --git a/components/messenger.rst b/components/messenger.rst index 33132889234..43272beb591 100644 --- a/components/messenger.rst +++ b/components/messenger.rst @@ -58,12 +58,12 @@ Concepts both when a message is originally dispatched and again later when a message is received from a transport, -**Envelope** +**Envelope**: Messenger specific concept, it gives full flexibility inside the message bus, by wrapping the messages into it, allowing to add useful information inside through *envelope stamps*. -**Envelope Stamps** +**Envelope Stamps**: Piece of information you need to attach to your message: serializer context to use for transport, markers identifying a received message or any sort of metadata your middleware or transport layer may use. diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 2cfbaa07376..3f6563afefa 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -952,7 +952,7 @@ your application, you can use your own SUT (System Under Test) solver: The ``My\Namespace\SutSolver::solve`` can be any PHP callable and receives the -current test classname as its first argument. +current test as its first argument. Finally, the listener can also display warning messages when the SUT solver does not find the SUT: diff --git a/service_container.rst b/service_container.rst index 27685eecf36..54e73645f60 100644 --- a/service_container.rst +++ b/service_container.rst @@ -295,13 +295,15 @@ made. To do that, you create a new class:: namespace App\Updates; use App\Service\MessageGenerator; + use Symfony\Component\Mailer\MailerInterface; + use Symfony\Component\Mime\Email; class SiteUpdateManager { private $messageGenerator; private $mailer; - public function __construct(MessageGenerator $messageGenerator, \Swift_Mailer $mailer) + public function __construct(MessageGenerator $messageGenerator, MailerInterface $mailer) { $this->messageGenerator = $messageGenerator; $this->mailer = $mailer; @@ -311,19 +313,21 @@ made. To do that, you create a new class:: { $happyMessage = $this->messageGenerator->getHappyMessage(); - $message = (new \Swift_Message('Site update just happened!')) - ->setFrom('admin@example.com') - ->setTo('manager@example.com') - ->addPart( - 'Someone just updated the site. We told them: '.$happyMessage - ); + $email = (new Email()) + ->from('admin@example.com') + ->to('manager@example.com') + ->subject('Site update just happened!') + ->text('Someone just updated the site. We told them: '.$happyMessage); - return $this->mailer->send($message) > 0; + $this->mailer->send($email); + + // ... } } -This needs the ``MessageGenerator`` *and* the ``Swift_Mailer`` service. That's no -problem! In fact, this new service is ready to be used. In a controller, for example, +This needs the ``MessageGenerator`` *and* the ``Mailer`` service. That's no +problem, we ask them by type hinting their class and interface names! +Now, this new service is ready to be used. In a controller, for example, you can type-hint the new ``SiteUpdateManager`` class and use it:: // src/Controller/SiteController.php