. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; use InvalidArgumentException; 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 RedirectSourcePhp implements RequestHandlerInterface { /** * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $tree = $request->getQueryParams()['ged']; assert(is_string($tree), new InvalidArgumentException()); $xref = $request->getQueryParams()['sid']; assert(is_string($xref), new InvalidArgumentException()); $url = route('source', ['tree' => $tree, 'xref' => $xref]); return redirect($url, StatusCodeInterface::STATUS_MOVED_PERMANENTLY); } }