‪TYPO3CMS  ‪main
FileUpdatedMessage.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/file-updated',
29  ‪description: 'LLL:EXT:webhooks/Resources/Private/Language/locallang_db.xlf:sys_webhook.webhook_type.typo3-file-updated'
30 )]
31 final class FileUpdatedMessage implements ‪WebhookMessageInterface
32 {
33  public function __construct(
34  private readonly int $storageUid,
35  private readonly string ‪$identifier,
36  private readonly ?string ‪$publicUrl,
37  private readonly array ‪$relevantProperties,
38  private readonly array $updatedFields
39  ) {}
40 
41  public static function createFromEvent(AfterFileUpdatedInIndexEvent $event): FileUpdatedMessage
42  {
43  $file = $event->getFile();
44  return new self($file->getStorage()->getUid(), $file->getIdentifier(), $file->getPublicUrl(), $event->getRelevantProperties(), $event->getUpdatedFields());
45  }
46 
47  public function jsonSerialize(): array
48  {
49  return [
50  'storage' => $this->storageUid,
51  'identifier' => ‪$this->identifier,
52  'url' => ‪$this->publicUrl,
53  'relevantProperties' => ‪$this->relevantProperties,
54  'updatedFields' => $this->updatedFields,
55  ];
56  }
57 }
‪TYPO3\CMS\Core\Resource\Event\AfterFileUpdatedInIndexEvent
Definition: AfterFileUpdatedInIndexEvent.php:27
‪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\$publicUrl
‪identifier readonly string readonly string $publicUrl
Definition: FileUpdatedMessage.php:36
‪TYPO3\CMS\Webhooks\Message\$relevantProperties
‪identifier readonly string readonly string readonly array $relevantProperties
Definition: FileUpdatedMessage.php:37
‪TYPO3\CMS\Webhooks\Message\description
‪identifier description
Definition: FileAddedMessage.php:36
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37