‪TYPO3CMS  ‪main
WebhookInstructionFactory.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 
24 
31 {
32  private static array ‪$defaults = [
33  'method' => 'POST',
34  'verify_ssl' => true,
35  'additional_headers' => [],
36  'name' => null,
37  'description' => null,
38  'webhook_type' => null,
39  'identifier' => null,
40  'uid' => null,
41  ];
42 
43  public static function ‪create(
44  string ‪$url,
45  string $secret,
46  string $method = 'POST',
47  bool $verifySSL = true,
48  array $additionalHeaders = [],
49  string $name = null,
50  string $description = null,
51  ‪WebhookType $webhookType = null,
52  string ‪$identifier = null,
53  int ‪$uid = null,
55  return new ‪WebhookInstruction(
56  ‪$url,
57  $secret,
58  $method,
59  $verifySSL,
60  $additionalHeaders,
61  $name,
62  $description,
63  $webhookType,
65  ‪$uid
66  );
67  }
68 
69  public static function ‪createFromRow(array $row): ‪WebhookInstruction
70  {
71  $data = array_merge(self::$defaults, $row);
72 
73  if ($data['webhook_type'] !== null) {
74  try {
75  $data['webhook_type'] = GeneralUtility::makeInstance(WebhookTypesRegistry::class)
76  ->getWebhookByType($data['webhook_type']);
77  } catch (\UnexpectedValueException $e) {
78  // Webhook type not found
79  $data['webhook_type'] = null;
80  }
81  }
82 
83  return new ‪WebhookInstruction(
84  $data['url'],
85  $data['secret'],
86  $data['method'],
87  (bool)$data['verify_ssl'],
88  $data['additional_headers'],
89  $data['name'],
90  $data['description'],
91  $data['webhook_type'],
92  $data['identifier'],
93  $data['uid'],
94  $row
95  );
96  }
97 }
‪TYPO3\CMS\Webhooks\WebhookTypesRegistry
Definition: WebhookTypesRegistry.php:29
‪TYPO3\CMS\Webhooks\Factory\WebhookInstructionFactory\create
‪static create(string $url, string $secret, string $method='POST', bool $verifySSL=true, array $additionalHeaders=[], string $name=null, string $description=null, WebhookType $webhookType=null, string $identifier=null, int $uid=null,)
Definition: WebhookInstructionFactory.php:43
‪TYPO3\CMS\Webhooks\Factory\WebhookInstructionFactory\createFromRow
‪static createFromRow(array $row)
Definition: WebhookInstructionFactory.php:69
‪TYPO3\CMS\Webhooks\Model\WebhookInstruction
Definition: WebhookInstruction.php:28
‪TYPO3\CMS\Webhooks\Message\$url
‪identifier readonly UriInterface $url
Definition: LoginErrorOccurredMessage.php:36
‪TYPO3\CMS\Webhooks\Factory
Definition: WebhookInstructionFactory.php:18
‪TYPO3\CMS\Webhooks\Message\$uid
‪identifier readonly int $uid
Definition: PageModificationMessage.php:35
‪TYPO3\CMS\Webhooks\Factory\WebhookInstructionFactory\$defaults
‪static array $defaults
Definition: WebhookInstructionFactory.php:32
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Webhooks\Model\WebhookType
Definition: WebhookType.php:24
‪TYPO3\CMS\Webhooks\Factory\WebhookInstructionFactory
Definition: WebhookInstructionFactory.php:31
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37