summaryrefslogtreecommitdiff
path: root/app/Http/RequestHandlers/RedirectNotePhp.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-10-10 22:00:26 +0100
committerGreg Roach <fisharebest@webtrees.net>2019-10-10 23:46:22 +0100
commitf2ab2ba5fcc699ce42eaea83251684d4f8551377 (patch)
treecee3c59237dbbdabc3c2c2e48f0c91edcd882cf1 /app/Http/RequestHandlers/RedirectNotePhp.php
parent258cb0319f38ed8b5437b9f6a834eeae05285a69 (diff)
downloadwebtrees-f2ab2ba5fcc699ce42eaea83251684d4f8551377.tar.gz
webtrees-f2ab2ba5fcc699ce42eaea83251684d4f8551377.tar.bz2
webtrees-f2ab2ba5fcc699ce42eaea83251684d4f8551377.zip
Use routing to redirect legacy URLs
Diffstat (limited to 'app/Http/RequestHandlers/RedirectNotePhp.php')
-rw-r--r--app/Http/RequestHandlers/RedirectNotePhp.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/app/Http/RequestHandlers/RedirectNotePhp.php b/app/Http/RequestHandlers/RedirectNotePhp.php
new file mode 100644
index 0000000000..af3e8aaa7a
--- /dev/null
+++ b/app/Http/RequestHandlers/RedirectNotePhp.php
@@ -0,0 +1,47 @@
+<?php
+
+/**
+ * webtrees: online genealogy
+ * Copyright (C) 2019 webtrees development team
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+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 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
+ {
+ $ged = $request->getQueryParams()['ged'] ?? '';
+ $xref = $request->getQueryParams()['nid'] ?? '';
+ $route = route('note', ['tree' => $ged, 'xref' => $xref]);
+
+ return redirect($route, StatusCodeInterface::STATUS_MOVED_PERMANENTLY);
+ }
+}