‪TYPO3CMS  ‪main
WebhookMessageFactory.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 
21 
26 {
27  public function ‪__construct(
28  protected readonly ‪WebhookTypesRegistry $typesRegistry
29  ) {}
30 
31  public function ‪createMessageFromEvent(object $eventObject): ?object
32  {
33  $eventName = get_class($eventObject);
34  $type = $this->typesRegistry->getWebhookByEventIdentifier($eventName);
35  if (!$type) {
36  return null;
37  }
38 
39  return $type->getFactoryMethod()($eventObject);
40  }
41 }
‪TYPO3\CMS\Webhooks\WebhookTypesRegistry
Definition: WebhookTypesRegistry.php:29
‪TYPO3\CMS\Webhooks\Message
Definition: FileAddedMessage.php:18
‪TYPO3\CMS\Webhooks\Message\WebhookMessageFactory\__construct
‪__construct(protected readonly WebhookTypesRegistry $typesRegistry)
Definition: WebhookMessageFactory.php:27
‪TYPO3\CMS\Webhooks\Message\WebhookMessageFactory\createMessageFromEvent
‪createMessageFromEvent(object $eventObject)
Definition: WebhookMessageFactory.php:31
‪TYPO3\CMS\Webhooks\Message\WebhookMessageFactory
Definition: WebhookMessageFactory.php:26