summaryrefslogtreecommitdiff
path: root/app/Http/RequestHandlers/ReorderChildrenPage.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-10-15 20:51:18 +0100
committerGreg Roach <fisharebest@webtrees.net>2019-10-15 23:05:57 +0100
commit5229eade2a8cdd1381e19f96f67fc1c8b92ca95d (patch)
tree007749d01fdfd56b668f6ecee309371b6a6d1a33 /app/Http/RequestHandlers/ReorderChildrenPage.php
parent9b5c959707d56fc73446942abbe205a42e3c07cf (diff)
downloadwebtrees-5229eade2a8cdd1381e19f96f67fc1c8b92ca95d.tar.gz
webtrees-5229eade2a8cdd1381e19f96f67fc1c8b92ca95d.tar.bz2
webtrees-5229eade2a8cdd1381e19f96f67fc1c8b92ca95d.zip
Refactor the re-ordering of children/spouses/names/media; add assertions
Diffstat (limited to 'app/Http/RequestHandlers/ReorderChildrenPage.php')
-rw-r--r--app/Http/RequestHandlers/ReorderChildrenPage.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/app/Http/RequestHandlers/ReorderChildrenPage.php b/app/Http/RequestHandlers/ReorderChildrenPage.php
new file mode 100644
index 0000000000..941e95c251
--- /dev/null
+++ b/app/Http/RequestHandlers/ReorderChildrenPage.php
@@ -0,0 +1,67 @@
+<?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 Fisharebest\Webtrees\Auth;
+use Fisharebest\Webtrees\Family;
+use Fisharebest\Webtrees\Http\ViewResponseTrait;
+use Fisharebest\Webtrees\I18N;
+use Fisharebest\Webtrees\Tree;
+use InvalidArgumentException;
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
+use Psr\Http\Server\RequestHandlerInterface;
+
+use function assert;
+use function is_string;
+
+/**
+ * Reorder the children in a family.
+ */
+class ReorderChildrenPage implements RequestHandlerInterface
+{
+ use ViewResponseTrait;
+
+ /**
+ * @param ServerRequestInterface $request
+ *
+ * @return ResponseInterface
+ */
+ public function handle(ServerRequestInterface $request): ResponseInterface
+ {
+ $tree = $request->getAttribute('tree');
+ assert($tree instanceof Tree, new InvalidArgumentException());
+
+ $xref = $request->getAttribute('xref');
+ assert(is_string($xref), new InvalidArgumentException());
+
+ $family = Family::getInstance($xref, $tree);
+ assert($family instanceof Family, new InvalidArgumentException());
+
+ Auth::checkFamilyAccess($family, true);
+
+ $title = $family->fullName() . ' — ' . I18N::translate('Re-order children');
+
+ return $this->viewResponse('edit/reorder-children', [
+ 'family' => $family,
+ 'title' => $title,
+ 'tree' => $tree,
+ ]);
+ }
+}