‪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 
44  public function jsonSerialize(): array
45  {
46  $data = [
47  'action' => $this->action,
48  'identifier' => ‪$this->uid,
49  'record' => ‪$this->record,
50  'url' => ‪$this->url,
51  'site' => ‪$this->siteIdentifier,
52  'workspace' => $this->record['t3ver_wsid'] ?? 0,
53  ];
54  if ($this->author instanceof BackendUserAuthentication) {
55  $data['author'] = [
56  'uid' => $this->author->user['uid'],
57  'username' => $this->author->user['username'],
58  'isAdmin' => $this->author->isAdmin(),
59  ];
60  }
61  if (is_array($this->modifiedFields)) {
62  $data['changedFields'] = $this->modifiedFields;
63  }
64  return $data;
65  }
66 }
‪TYPO3\CMS\Core\Attribute\WebhookMessage
Definition: WebhookMessage.php:27
‪TYPO3\CMS\Webhooks\Message
Definition: FileAddedMessage.php:18
‪TYPO3\CMS\Core\Messaging\WebhookMessageInterface
Definition: WebhookMessageInterface.php:29
‪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:66
‪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