TransportLocator implements SendersLocatorInterface

Read onlyYes

A locator that returns the senders (transports) a message should be routed to.

Routing is configured via $GLOBALS['TYPO3_CONF_VARS']['SYS']['messenger']['routing'], a map of message type to one or more transport identifiers. A routing value may be a single transport identifier (string) or an ordered list of transport identifiers (array) to route a single message to multiple transports.

The routing keys (the "types") are matched against the type chain of the dispatched message, which is derived from the message's PHP type - not from the order of the routing configuration. The chain, as produced by HandlersLocator::listTypes(), is, from most to least specific: the message class, its parent classes, its implemented interfaces, the namespace wildcards for every namespace level (My\Sub\Message*, My\Sub*, My*) and finally the global wildcard '*'.

Resolution rules:

  1. An explicit TransportNamesStamp on the envelope always wins.
  2. Otherwise senders are collected across every matching type in that type chain order, deduplicated (first occurrence wins).
  3. A wildcard route - a namespace wildcard (My\Message*) or the global '*' - acts as a fallback: it is skipped as soon as a more specific type already matched, and only applies when no specific route matched. This mirrors the upstream Symfony SendersLocator and removes the need to unset a wildcard route to keep a message on its specific transport only.
Internal

Table of Contents

Interfaces

SendersLocatorInterface

Methods

__construct()  : mixed
getSenderNamesForMessage()  : array<int, string>
Resolves the configured transport (sender) names for a message class, applying the exact same routing resolution as getSenders() - including the wildcard fallback and value normalization - but without requiring a message instance/envelope and without instantiating the senders. Only the sender identifiers are returned; unregistered identifiers are not validated here.
getSenders()  : iterable<string|int, mixed>

Methods

__construct()

public __construct(ContainerInterface $sendersLocator) : mixed
Parameters
$sendersLocator : ContainerInterface

getSenderNamesForMessage()

Resolves the configured transport (sender) names for a message class, applying the exact same routing resolution as getSenders() - including the wildcard fallback and value normalization - but without requiring a message instance/envelope and without instantiating the senders. Only the sender identifiers are returned; unregistered identifiers are not validated here.

public getSenderNamesForMessage(class-string $messageClass) : array<int, string>
Parameters
$messageClass : class-string
Return values
array<int, string>

getSenders()

public getSenders(Envelope $envelope) : iterable<string|int, mixed>
Parameters
$envelope : Envelope
Return values
iterable<string|int, mixed>
On this page

Search results