Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 10f46eb

Browse filesBrowse files
srozeweaverryan
authored andcommitted
Introduce the TransportInterface
1 parent ef70bc0 commit 10f46eb
Copy full SHA for 10f46eb

File tree

1 file changed

+26
-8
lines changed
Filter options

1 file changed

+26
-8
lines changed

‎messenger.rst

Copy file name to clipboardExpand all lines: messenger.rst
+26-8Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,30 +279,48 @@ Once you have written your transport's sender and receiver, you can register you
279279
transport factory to be able to use it via a DSN in the Symfony application.
280280

281281
Create your Transport Factory
282-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
282+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
283283

284284
You need to give FrameworkBundle the opportunity to create your transport from a
285285
DSN. You will need an transport factory::
286286

287-
use Symfony\Component\Messenger\Transport\Factory\AdapterFactoryInterface;
287+
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
288+
use Symfony\Component\Messenger\Transport\TransportInterface;
288289
use Symfony\Component\Messenger\Transport\ReceiverInterface;
289290
use Symfony\Component\Messenger\Transport\SenderInterface;
290291

291292
class YourTransportFactory implements TransportFactoryInterface
292293
{
293-
public function createReceiver(string $dsn, array $options): ReceiverInterface
294+
public function createTransport(string $dsn, array $options): TransportInterface
294295
{
295-
return new YourReceiver(/* ... */);
296+
return new YourTransport(/* ... */);
296297
}
297298

298-
public function createSender(string $dsn, array $options): SenderInterface
299+
public function supports(string $dsn, array $options): bool
299300
{
300-
return new YourSender(/* ... */);
301+
return 0 === strpos($dsn, 'my-transport://');
301302
}
303+
}
302304

303-
public function supports(string $dsn, array $options): bool
305+
The transport object is needs to implements the ``TransportInterface`` (which simply combine
306+
the ``SenderInterface`` and ``ReceiverInterface``). It will look
307+
like this::
308+
309+
class YourTransport implements TransportInterface
310+
{
311+
public function send($message) : void
304312
{
305-
return 0 === strpos($dsn, 'my-transport://');
313+
// ...
314+
}
315+
316+
public function receive(callable $handler) : void
317+
{
318+
// ...
319+
}
320+
321+
public function stop() : void
322+
{
323+
// ...
306324
}
307325
}
308326

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.