‪TYPO3CMS  ‪main
PageModificationMessage.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 
23 
27 #[WebhookMessage(
28  identifier: 'typo3/content/page-modification',
29  ‪description: 'LLL:EXT:webhooks/Resources/Private/Language/locallang_db.xlf:sys_webhook.webhook_type.typo3-content-page-modification'
30 )]
31 final class PageModificationMessage implements ‪WebhookMessageInterface
32 {
33  public function __construct(
34  private readonly string $action,
35  private readonly int ‪$uid,
36  private readonly array ‪$record,
37  private readonly string ‪$url,
38  private readonly string ‪$siteIdentifier,
39  private readonly ?‪BackendUserAuthentication ‪$author = null,
40  private readonly ?array $modifiedFields = null
41  ) {}
42 
43  public function jsonSerialize(): array
44  {
45  $data = [
46  'action' => $this->action,
47  'identifier' => ‪$this->uid,
48  'record' => ‪$this->record,
49  'url' => ‪$this->url,
50  'site' => ‪$this->siteIdentifier,
51  'workspace' => $this->record['t3ver_wsid'] ?? 0,
52  ];
53  if ($this->author instanceof BackendUserAuthentication) {
54  $data['author'] = [
55  'uid' => $this->author->user['uid'],
56  'username' => $this->author->user['username'],
57  'isAdmin' => $this->author->isAdmin(),
58  ];
59  }
60  if (is_array($this->modifiedFields)) {
61  $data['changedFields'] = $this->modifiedFields;
62  }
63  return $data;
64  }
65 }
‪TYPO3\CMS\Core\Attribute\WebhookMessage
Definition: WebhookMessage.php:25
‪TYPO3\CMS\Webhooks\Message
Definition: FileAddedMessage.php:18
‪TYPO3\CMS\Core\Messaging\WebhookMessageInterface
Definition: WebhookMessageInterface.php:28
‪TYPO3\CMS\Webhooks\Message\description
‪identifier description
Definition: FileAddedMessage.php:36
‪TYPO3\CMS\Webhooks\Message\$record
‪identifier readonly int readonly array $record
Definition: PageModificationMessage.php:36
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Webhooks\Message\$author
‪identifier readonly int readonly array readonly string readonly string readonly BackendUserAuthentication $author
Definition: PageModificationMessage.php:39
‪TYPO3\CMS\Webhooks\Message\$url
‪identifier readonly UriInterface $url
Definition: LoginErrorOccurredMessage.php:36
‪TYPO3\CMS\Webhooks\Message\$uid
‪identifier readonly int $uid
Definition: PageModificationMessage.php:35
‪TYPO3\CMS\Webhooks\Message\$siteIdentifier
‪identifier readonly int readonly array readonly string readonly string $siteIdentifier
Definition: PageModificationMessage.php:38