xref: /webtrees/app/Http/RequestHandlers/ChangeFamilyMembersPage.php (revision 58a588c63196cb1f4cc1926f6fe552c754b0d27a)
143322877SGreg Roach<?php
243322877SGreg Roach
343322877SGreg Roach/**
443322877SGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
643322877SGreg Roach * This program is free software: you can redistribute it and/or modify
743322877SGreg Roach * it under the terms of the GNU General Public License as published by
843322877SGreg Roach * the Free Software Foundation, either version 3 of the License, or
943322877SGreg Roach * (at your option) any later version.
1043322877SGreg Roach * This program is distributed in the hope that it will be useful,
1143322877SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1243322877SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1343322877SGreg Roach * GNU General Public License for more details.
1443322877SGreg 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/>.
1643322877SGreg Roach */
1743322877SGreg Roach
1843322877SGreg Roachdeclare(strict_types=1);
1943322877SGreg Roach
2043322877SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
2143322877SGreg Roach
2243322877SGreg Roachuse Fisharebest\Webtrees\Auth;
2343322877SGreg Roachuse Fisharebest\Webtrees\Http\ViewResponseTrait;
2443322877SGreg Roachuse Fisharebest\Webtrees\I18N;
256b9cb339SGreg Roachuse Fisharebest\Webtrees\Registry;
26b55cbc6bSGreg Roachuse Fisharebest\Webtrees\Validator;
2743322877SGreg Roachuse Psr\Http\Message\ResponseInterface;
2843322877SGreg Roachuse Psr\Http\Message\ServerRequestInterface;
2943322877SGreg Roachuse Psr\Http\Server\RequestHandlerInterface;
3043322877SGreg Roach
3143322877SGreg Roach/**
3243322877SGreg Roach * Change the members of a family.
3343322877SGreg Roach */
3443322877SGreg Roachclass ChangeFamilyMembersPage implements RequestHandlerInterface
3543322877SGreg Roach{
3643322877SGreg Roach    use ViewResponseTrait;
3743322877SGreg Roach
3843322877SGreg Roach    public function handle(ServerRequestInterface $request): ResponseInterface
3943322877SGreg Roach    {
40b55cbc6bSGreg Roach        $tree   = Validator::attributes($request)->tree();
41748dbe15SGreg Roach        $xref   = Validator::queryParams($request)->string('xref');
426b9cb339SGreg Roach        $family = Registry::familyFactory()->make($xref, $tree);
4343322877SGreg Roach        $family = Auth::checkFamilyAccess($family, true);
4443322877SGreg Roach        $title  = I18N::translate('Change family members') . ' – ' . $family->fullName();
4543322877SGreg Roach
4643322877SGreg Roach        return $this->viewResponse('edit/change-family-members', [
4743322877SGreg Roach            'tree'   => $tree,
4843322877SGreg Roach            'title'  => $title,
4943322877SGreg Roach            'family' => $family,
5043322877SGreg Roach        ]);
5143322877SGreg Roach    }
5243322877SGreg Roach}
53