diff --git a/Classes/Transport/FailureTransportContainer.php b/Classes/Transport/FailureTransportContainer.php new file mode 100644 index 0000000..463e6ca --- /dev/null +++ b/Classes/Transport/FailureTransportContainer.php @@ -0,0 +1,33 @@ +transports[$id]; + } + + public function has(string $id) + { + return isset($this->transports[$id]); + } + + public function set(string $id, TransportInterface $transport) + { + $this->transports[$id] = $transport; + } +} diff --git a/Classes/Transport/TransportsContainer.php b/Classes/Transport/TransportsContainer.php index d96a752..8d29e5a 100644 --- a/Classes/Transport/TransportsContainer.php +++ b/Classes/Transport/TransportsContainer.php @@ -31,6 +31,12 @@ class TransportsContainer implements ContainerInterface */ protected $transportFactory; + /** + * @Flow\Inject + * @var FailureTransportContainer + */ + protected $failureTransports; + /** * @var TransportInterface[] */ @@ -65,6 +71,11 @@ class TransportsContainer implements ContainerInterface $transportDefinition['options'], $this->objectManager->get($transportDefinition['serializer']) ); + if (isset($transportDefinition['failureTransport'])) { + $this->failureTransports->set($id, $this->get($transportDefinition['failureTransport'])); + } elseif (isset($this->configuration['failureTransport'])) { + $this->failureTransports->set($id, $this->get($this->configuration['failureTransport'])); + } } return $this->transports[$id]; } diff --git a/Configuration/Objects.yaml b/Configuration/Objects.yaml index 380de1e..6e2d395 100644 --- a/Configuration/Objects.yaml +++ b/Configuration/Objects.yaml @@ -89,6 +89,13 @@ DigiComp.FlowSymfonyBridge.Messenger:ReceiversContainer: object: 'DigiComp\FlowSymfonyBridge\Messenger\Transport\TransportsContainer' # TODO: add own receivers here, which are no transports +DigiComp.FlowSymfonyBridge.Messenger:FailureSenderContainer: + className: 'DigiComp\FlowSymfonyBridge\Messenger\ObjectManagement\ChainedContainer' + scope: 'singleton' + arguments: + 1: + object: 'DigiComp\FlowSymfonyBridge\Messenger\Transport\FailureTransportContainer' + DigiComp.FlowSymfonyBridge.Messenger:EventDispatcher: className: 'Symfony\Component\EventDispatcher\EventDispatcher' scope: 'singleton' @@ -133,10 +140,6 @@ Symfony\Component\Messenger\EventListener\SendFailedMessageToFailureTransportLis arguments: 1: object: - factoryObjectName: 'DigiComp.FlowSymfonyBridge.Messenger:SendersContainer' - factoryMethodName: 'get' - arguments: - 1: - setting: 'DigiComp.FlowSymfonyBridge.Messenger.failureTransport' + name: 'DigiComp.FlowSymfonyBridge.Messenger:FailureSenderContainer' 2: object: 'Psr\Log\LoggerInterface'