xref: /webtrees/app/Http/RequestHandlers/ReorderChildrenPage.php (revision d11be7027e34e3121be11cc025421873364403f9)
15229eadeSGreg Roach<?php
25229eadeSGreg Roach
35229eadeSGreg Roach/**
45229eadeSGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
65229eadeSGreg Roach * This program is free software: you can redistribute it and/or modify
75229eadeSGreg Roach * it under the terms of the GNU General Public License as published by
85229eadeSGreg Roach * the Free Software Foundation, either version 3 of the License, or
95229eadeSGreg Roach * (at your option) any later version.
105229eadeSGreg Roach * This program is distributed in the hope that it will be useful,
115229eadeSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
125229eadeSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
135229eadeSGreg Roach * GNU General Public License for more details.
145229eadeSGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
165229eadeSGreg Roach */
17fcfa147eSGreg Roach
185229eadeSGreg Roachdeclare(strict_types=1);
195229eadeSGreg Roach
205229eadeSGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
215229eadeSGreg Roach
225229eadeSGreg Roachuse Fisharebest\Webtrees\Auth;
235229eadeSGreg Roachuse Fisharebest\Webtrees\Http\ViewResponseTrait;
245229eadeSGreg Roachuse Fisharebest\Webtrees\I18N;
256b9cb339SGreg Roachuse Fisharebest\Webtrees\Registry;
26b55cbc6bSGreg Roachuse Fisharebest\Webtrees\Validator;
275229eadeSGreg Roachuse Psr\Http\Message\ResponseInterface;
285229eadeSGreg Roachuse Psr\Http\Message\ServerRequestInterface;
295229eadeSGreg Roachuse Psr\Http\Server\RequestHandlerInterface;
305229eadeSGreg Roach
315229eadeSGreg Roach/**
325229eadeSGreg Roach * Reorder the children in a family.
335229eadeSGreg Roach */
345229eadeSGreg Roachclass ReorderChildrenPage implements RequestHandlerInterface
355229eadeSGreg Roach{
365229eadeSGreg Roach    use ViewResponseTrait;
375229eadeSGreg Roach
385229eadeSGreg Roach    /**
395229eadeSGreg Roach     * @param ServerRequestInterface $request
405229eadeSGreg Roach     *
415229eadeSGreg Roach     * @return ResponseInterface
425229eadeSGreg Roach     */
435229eadeSGreg Roach    public function handle(ServerRequestInterface $request): ResponseInterface
445229eadeSGreg Roach    {
45b55cbc6bSGreg Roach        $tree   = Validator::attributes($request)->tree();
46b55cbc6bSGreg Roach        $xref   = Validator::attributes($request)->isXref()->string('xref');
476b9cb339SGreg Roach        $family = Registry::familyFactory()->make($xref, $tree);
48ddeb3354SGreg Roach        $family = Auth::checkFamilyAccess($family, true);
4950405528SGreg Roach        $url    = Validator::queryParams($request)->isLocalUrl()->string('url', $family->url());
505229eadeSGreg Roach
515229eadeSGreg Roach        $title = $family->fullName() . ' — ' . I18N::translate('Re-order children');
525229eadeSGreg Roach
535229eadeSGreg Roach        return $this->viewResponse('edit/reorder-children', [
545229eadeSGreg Roach            'family' => $family,
555229eadeSGreg Roach            'title'  => $title,
565229eadeSGreg Roach            'tree'   => $tree,
5750405528SGreg Roach            'url'    => $url,
585229eadeSGreg Roach        ]);
595229eadeSGreg Roach    }
605229eadeSGreg Roach}
61