AfterPageUrlsForSiteForRedirectIntegrityHaveBeenCollectedEvent 

New in version 14.0

The PSR-14 event \TYPO3\CMS\Redirects\Event\AfterPageUrlsForSiteForRedirectIntegrityHaveBeenCollectedEvent allows TYPO3 Extensions to register event listeners to modify the list of URLs that are being processed by the CLI command redirects:checkintegrity.

Example: Add the URLs of the XML sitemap to the integrity check 

The event listener class, using the PHP attribute #[AsEventListener] for registration, adds the URLs found in a sites XML sitemap to the list of URLs.

EXT:my_extension/Classes/Redirects/EventListener/MyEventListener.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Redirects\EventListener;

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Http\RequestFactory;
use TYPO3\CMS\Redirects\Event\AfterPageUrlsForSiteForRedirectIntegrityHaveBeenCollectedEvent;

final class MyEventListener
{
  public function __construct(
    private RequestFactory $requestFactory,
  ) {}

  #[AsEventListener]
  public function __invoke(AfterPageUrlsForSiteForRedirectIntegrityHaveBeenCollectedEvent $event): void
  {
    $pageUrls = $event->getPageUrls();

    $additionalOptions = [
      'headers' => ['Cache-Control' => 'no-cache'],
      'allow_redirects' => false,
    ];

    $site = $event->getSite();
    foreach ($site->getLanguages() as $siteLanguage) {
      $sitemapIndexUrl = rtrim((string)$siteLanguage->getBase(), '/') . '/sitemap.xml';
      $response = $this->requestFactory->request(
        $sitemapIndexUrl,
        'GET',
        $additionalOptions,
      );
      $sitemapIndex = simplexml_load_string($response->getBody()->getContents());
      foreach ($sitemapIndex as $sitemap) {
        $sitemapUrl = (string)$sitemap->loc;
        $response = $this->requestFactory->request(
          $sitemapUrl,
          'GET',
          $additionalOptions,
        );
        $sitemap = simplexml_load_string($response->getBody()->getContents());
        foreach ($sitemap as $url) {
          $pageUrls[] = (string)$url->loc;
        }
      }
    }

    $event->setPageUrls($pageUrls);
  }
}
Copied!

API 

final class AfterPageUrlsForSiteForRedirectIntegrityHaveBeenCollectedEvent
Fully qualified name
\TYPO3\CMS\Redirects\Event\AfterPageUrlsForSiteForRedirectIntegrityHaveBeenCollectedEvent

This event is fired in \TYPO3\CMS\Redirects\Service\IntegrityService->getAllPageUrlsForSite() to gather URLs of subpages for a given site.

getSite()
Returns
\TYPO3\CMS\Core\Site\Entity\Site
setPageUrls(array $pageUrls)
param $pageUrls

the pageUrls

getPageUrls()
Returns
array