‪TYPO3CMS  ‪main
RedirectWasHitMessage.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 
20 use Psr\Http\Message\UriInterface;
24 
25 #[WebhookMessage(
26  identifier: 'typo3/redirect-was-hit',
27  ‪description: 'LLL:EXT:redirects/Resources/Private/Language/locallang_db.xlf:sys_redirect.webhook_type.typo3-redirect-was-hit'
28 )]
29 final class RedirectWasHitMessage implements ‪WebhookMessageInterface
30 {
31  public function __construct(
32  private readonly UriInterface $sourceUrl,
33  private readonly UriInterface ‪$targetUrl,
34  private readonly int ‪$statusCode,
35  private readonly array ‪$matchedRedirect,
36  ) {}
37 
38  public static function createFromEvent(RedirectWasHitEvent $event): self
39  {
40  return new self(
41  $event->getRequest()->getUri(),
42  $event->getTargetUrl(),
43  $event->getResponse()->getStatusCode(),
44  $event->getMatchedRedirect(),
45  );
46  }
47 
48  public function jsonSerialize(): array
49  {
50  return [
51  'sourceUrl' => (string)$this->sourceUrl,
52  'targetUrl' => (string)‪$this->targetUrl,
53  'statusCode' => ‪$this->statusCode,
54  'redirect' => ‪$this->matchedRedirect,
55  ];
56  }
57 }
‪TYPO3\CMS\Core\Attribute\WebhookMessage
Definition: WebhookMessage.php:25
‪TYPO3\CMS\Redirects\Message\$targetUrl
‪identifier readonly UriInterface $targetUrl
Definition: RedirectWasHitMessage.php:33
‪TYPO3\CMS\Core\Messaging\WebhookMessageInterface
Definition: WebhookMessageInterface.php:28
‪TYPO3\CMS\Redirects\Message\$statusCode
‪identifier readonly UriInterface readonly int $statusCode
Definition: RedirectWasHitMessage.php:34
‪TYPO3\CMS\Redirects\Message
Definition: RedirectWasHitMessage.php:18
‪TYPO3\CMS\Redirects\Message\$matchedRedirect
‪identifier readonly UriInterface readonly int readonly array $matchedRedirect
Definition: RedirectWasHitMessage.php:35
‪TYPO3\CMS\Redirects\Message\description
‪identifier description
Definition: RedirectWasHitMessage.php:32
‪TYPO3\CMS\Redirects\Event\RedirectWasHitEvent
Definition: RedirectWasHitEvent.php:33