diff --git a/typo3/sysext/webhooks/Classes/ConfigurationModuleProvider/WebhookTypesProvider.php b/typo3/sysext/webhooks/Classes/ConfigurationModuleProvider/WebhookTypesProvider.php index d9f75cb286eb34ac27a5913e9ca29d6424a2db6e..050f7fcfe1ffa35b459eca873b5694e775149384 100644 --- a/typo3/sysext/webhooks/Classes/ConfigurationModuleProvider/WebhookTypesProvider.php +++ b/typo3/sysext/webhooks/Classes/ConfigurationModuleProvider/WebhookTypesProvider.php @@ -17,7 +17,10 @@ declare(strict_types=1); namespace TYPO3\CMS\Webhooks\ConfigurationModuleProvider; +use Symfony\Component\DependencyInjection\ServiceLocator; +use TYPO3\CMS\Core\Messaging\WebhookMessageInterface; use TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\AbstractProvider; +use TYPO3\CMS\Webhooks\Model\WebhookType; use TYPO3\CMS\Webhooks\WebhookTypesRegistry; /** @@ -28,7 +31,8 @@ use TYPO3\CMS\Webhooks\WebhookTypesRegistry; class WebhookTypesProvider extends AbstractProvider { public function __construct( - private readonly WebhookTypesRegistry $webhookTypesRegistry + private readonly WebhookTypesRegistry $webhookTypesRegistry, + private readonly ServiceLocator $sendersLocator, ) { } @@ -40,8 +44,29 @@ class WebhookTypesProvider extends AbstractProvider 'messageName' => $webhookType->getServiceName(), 'description' => $webhookType->getDescription(), 'connectedEvent' => $webhookType->getConnectedEvent() ?? 'none', + 'transport' => $this->determineTransportForWebhook($webhookType), ]; } return $configuration; } + + /** + * @param WebhookType $webhookType + * @return array{identifier: non-empty-string, serviceName: non-empty-string} + */ + private function determineTransportForWebhook(WebhookType $webhookType): array + { + $transportName = + $GLOBALS['TYPO3_CONF_VARS']['SYS']['messenger']['routing'][$webhookType->getServiceName()] + ?? $GLOBALS['TYPO3_CONF_VARS']['SYS']['messenger']['routing'][WebhookMessageInterface::class] + ?? $GLOBALS['TYPO3_CONF_VARS']['SYS']['messenger']['routing']['*'] + ?? 'undefined'; + + return [ + 'identifier' => $transportName, + 'serviceName' => $this->sendersLocator->has($transportName) + ? get_class($this->sendersLocator->get($transportName)) + : 'undefined', + ]; + } } diff --git a/typo3/sysext/webhooks/Configuration/Services.yaml b/typo3/sysext/webhooks/Configuration/Services.yaml index 15f3772aa4ecc1995e7e329e4e4a8349076aaa39..eb5ce35fc0c7111c0212e6a048a21c22ee9ffca1 100644 --- a/typo3/sysext/webhooks/Configuration/Services.yaml +++ b/typo3/sysext/webhooks/Configuration/Services.yaml @@ -31,6 +31,8 @@ services: lowlevel.configuration.module.provider.webhooks: class: 'TYPO3\CMS\Webhooks\ConfigurationModuleProvider\WebhookTypesProvider' + arguments: + $sendersLocator: !tagged_locator { tag: 'messenger.sender', index_by: 'identifier' } tags: - name: 'lowlevel.configuration.module.provider' identifier: 'webhooks'