. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function assert; use function is_string; use function redirect; use function route; /** * Redirect URLs created by webtrees 1.x (and PhpGedView). */ class RedirectNotePhp implements RequestHandlerInterface { /** * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $tree = $request->getQueryParams()['ged']; assert(is_string($tree)); $xref = $request->getQueryParams()['nid'] ?? ''; assert(is_string($xref)); $url = route('note', ['tree' => $tree, 'xref' => $xref]); return redirect($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY); } }