Files
typo3-13/packages/ep_theme/Classes/Middleware/ReferrerMiddleware.php
T
frommeandClaude Opus 5.5 114a45aed3 chore: retire the snow report and search bar islands
They only served the static pages of the hybrid setup, which are retired:
TYPO3 13 renders search bar and snow reports in the page itself. Removed
are the page types 1705 (/snowreport) and 1706/1707 (/searchbar,
/searchbar-collapsed), their PageType enhancer entries and the id wrapper
of the snow report list that the static pages selected.

Also gone: the remarks about static pages and docroots in
ReferrerMiddleware and .htaccess.

The form page type (/form, 1704) stays for now; forms move off it in a
separate step.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 09:31:55 +01:00

43 lines
1.5 KiB
PHP

<?php
namespace EP\EpTheme\Middleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
/**
* Links to a form page carry the uid of the page they come from (?ref=123, e.g. the enquiry
* button of a product page). Its URL is kept in the session until AddReferrerFinisher puts it
* into the submission.
*/
class ReferrerMiddleware implements MiddlewareInterface
{
public const SESSION_KEY = 'referrer';
public function __construct(private readonly SiteFinder $siteFinder) {}
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$ref = $request->getQueryParams()['ref'] ?? null;
$frontendUser = $request->getAttribute('frontend.user');
if (!is_numeric($ref) || !$frontendUser instanceof FrontendUserAuthentication) {
return $handler->handle($request);
}
try {
$url = (string)$this->siteFinder->getSiteByPageId((int)$ref)->getRouter()->generateUri((int)$ref);
$frontendUser->setKey('ses', self::SESSION_KEY, $url);
$frontendUser->storeSessionData();
} catch (SiteNotFoundException) {
}
return $handler->handle($request);
}
}