W3cubDocs

/Symfony 4.1

MessageSubscriberInterface

interface MessageSubscriberInterface implements MessageHandlerInterface

Handlers can implement this interface to handle multiple messages.

Methods

static iterable getHandledMessages()

Returns a list of messages to be handled.

Details

static iterable getHandledMessages()

Returns a list of messages to be handled.

It returns a list of messages like in the following example:

return [MyMessage::class];

It can also change the priority per classes.

return [
    [FirstMessage::class, 0],
    [SecondMessage::class, -10],
];

It can also specify a method and/or a priority per message:

return [
    FirstMessage::class => 'firstMessageMethod',
    SecondMessage::class => ['secondMessageMethod', 20],
];

The __invoke method of the handler will be called as usual with the message to handle.

Return Value

iterable

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Messenger/Handler/MessageSubscriberInterface.html