Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit10f46eb

Browse files
srozeweaverryan
authored andcommitted
Introduce theTransportInterface
1 parentef70bc0 commit10f46eb

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

‎messenger.rst‎

Lines 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 functioncreateReceiver(string $dsn, array $options):ReceiverInterface
294+
public functioncreateTransport(string $dsn, array $options):TransportInterface
294295
{
295-
return newYourReceiver(/* ... */);
296+
return newYourTransport(/* ... */);
296297
}
297298

298-
public functioncreateSender(string $dsn, array $options):SenderInterface
299+
public functionsupports(string $dsn, array $options):bool
299300
{
300-
returnnew YourSender(/* ... */);
301+
return0 === 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)

[8]ページ先頭

©2009-2025 Movatter.jp