‪TYPO3CMS  ‪main
WebhookTypesRegistry.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 
18 namespace ‪TYPO3\CMS\Webhooks;
19 
21 
29 {
33  private array ‪$webhookTypes = [];
34 
38  public function ‪getAvailableWebhookTypes(): array
39  {
41  }
42 
46  public function ‪hasWebhookType(string $type): bool
47  {
48  return isset($this->webhookTypes[$type]);
49  }
50 
51  public function ‪getWebhookByType(string $type): ‪WebhookType
52  {
53  if (!$this->‪hasWebhookType($type)) {
54  throw new \UnexpectedValueException('No webhook with type ' . $type . ' registered.', 1679348837);
55  }
56 
57  return $this->webhookTypes[$type];
58  }
59 
60  public function ‪getWebhookByEventIdentifier(string $eventIdentifier): ?‪WebhookType
61  {
62  foreach ($this->webhookTypes as $type) {
63  if ($type->getConnectedEvent() === $eventIdentifier) {
64  return $type;
65  }
66  }
67  return null;
68  }
69 
70  public function ‪addWebhookType(string ‪$identifier, string $description, string $serviceName, string $factoryMethod, ?string $connectedEvent): void
71  {
72  $this->webhookTypes[‪$identifier] = new ‪WebhookType(‪$identifier, $description, $serviceName, $factoryMethod, $connectedEvent);
73  }
74 }
‪TYPO3\CMS\Webhooks\WebhookTypesRegistry
Definition: WebhookTypesRegistry.php:29
‪TYPO3\CMS\Webhooks\WebhookTypesRegistry\getWebhookByEventIdentifier
‪getWebhookByEventIdentifier(string $eventIdentifier)
Definition: WebhookTypesRegistry.php:60
‪TYPO3\CMS\Webhooks\WebhookTypesRegistry\getAvailableWebhookTypes
‪WebhookType[] getAvailableWebhookTypes()
Definition: WebhookTypesRegistry.php:38
‪TYPO3\CMS\Webhooks
‪TYPO3\CMS\Webhooks\WebhookTypesRegistry\hasWebhookType
‪hasWebhookType(string $type)
Definition: WebhookTypesRegistry.php:46
‪TYPO3\CMS\Webhooks\WebhookTypesRegistry\$webhookTypes
‪array $webhookTypes
Definition: WebhookTypesRegistry.php:33
‪TYPO3\CMS\Webhooks\WebhookTypesRegistry\getWebhookByType
‪getWebhookByType(string $type)
Definition: WebhookTypesRegistry.php:51
‪TYPO3\CMS\Webhooks\WebhookTypesRegistry\addWebhookType
‪addWebhookType(string $identifier, string $description, string $serviceName, string $factoryMethod, ?string $connectedEvent)
Definition: WebhookTypesRegistry.php:70
‪TYPO3\CMS\Webhooks\Model\WebhookType
Definition: WebhookType.php:24
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37