‪TYPO3CMS  ‪main
WebhookTypesProvider.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Symfony\Component\DependencyInjection\ServiceLocator;
25 
31 class WebhookTypesProvider extends ‪AbstractProvider
32 {
33  public function __construct(
34  private readonly ‪WebhookTypesRegistry $webhookTypesRegistry,
35  private readonly ServiceLocator $sendersLocator,
36  ) {}
37 
38  public function getConfiguration(): array
39  {
40  $configuration = [];
41  foreach ($this->webhookTypesRegistry->getAvailableWebhookTypes() as ‪$identifier => $webhookType) {
42  $configuration[‪$identifier] = [
43  'messageName' => $webhookType->getServiceName(),
44  'description' => $webhookType->getDescription(),
45  'connectedEvent' => $webhookType->getConnectedEvent() ?? 'none',
46  'transport' => $this->determineTransportForWebhook($webhookType),
47  ];
48  }
49  return $configuration;
50  }
51 
56  private function determineTransportForWebhook(WebhookType $webhookType): array
57  {
58  $transportName =
59  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['messenger']['routing'][$webhookType->getServiceName()]
60  ?? ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['messenger']['routing'][WebhookMessageInterface::class]
61  ?? ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['messenger']['routing']['*']
62  ?? 'undefined';
63 
64  return [
65  'identifier' => $transportName,
66  'serviceName' => $this->sendersLocator->has($transportName)
67  ? get_class($this->sendersLocator->get($transportName))
68  : 'undefined',
69  ];
70  }
71 }
‪TYPO3\CMS\Webhooks\ConfigurationModuleProvider
Definition: WebhookTypesProvider.php:18
‪TYPO3\CMS\Webhooks\WebhookTypesRegistry
Definition: WebhookTypesRegistry.php:29
‪TYPO3\CMS\Core\Messaging\WebhookMessageInterface
Definition: WebhookMessageInterface.php:28
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\AbstractProvider
Definition: AbstractProvider.php:27
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Webhooks\Model\WebhookType
Definition: WebhookType.php:24
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37