15229eadeSGreg Roach<?php 25229eadeSGreg Roach 35229eadeSGreg Roach/** 45229eadeSGreg Roach * webtrees: online genealogy 5a091ac74SGreg Roach * Copyright (C) 2020 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 155229eadeSGreg Roach * along with this program. If not, see <http://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; 25*6b9cb339SGreg Roachuse Fisharebest\Webtrees\Registry; 265229eadeSGreg Roachuse Fisharebest\Webtrees\Tree; 275229eadeSGreg Roachuse Psr\Http\Message\ResponseInterface; 285229eadeSGreg Roachuse Psr\Http\Message\ServerRequestInterface; 295229eadeSGreg Roachuse Psr\Http\Server\RequestHandlerInterface; 305229eadeSGreg Roach 315229eadeSGreg Roachuse function assert; 325229eadeSGreg Roachuse function is_string; 335229eadeSGreg Roach 345229eadeSGreg Roach/** 355229eadeSGreg Roach * Reorder the names of an individual. 365229eadeSGreg Roach */ 375229eadeSGreg Roachclass ReorderNamesPage implements RequestHandlerInterface 385229eadeSGreg Roach{ 395229eadeSGreg Roach use ViewResponseTrait; 405229eadeSGreg Roach 415229eadeSGreg Roach /** 425229eadeSGreg Roach * @param ServerRequestInterface $request 435229eadeSGreg Roach * 445229eadeSGreg Roach * @return ResponseInterface 455229eadeSGreg Roach */ 465229eadeSGreg Roach public function handle(ServerRequestInterface $request): ResponseInterface 475229eadeSGreg Roach { 485229eadeSGreg Roach $tree = $request->getAttribute('tree'); 4975964c75SGreg Roach assert($tree instanceof Tree); 505229eadeSGreg Roach 51745148ddSGreg Roach $xref = $request->getAttribute('xref'); 5275964c75SGreg Roach assert(is_string($xref)); 535229eadeSGreg Roach 54*6b9cb339SGreg Roach $individual = Registry::individualFactory()->make($xref, $tree); 55ddeb3354SGreg Roach $individual = Auth::checkIndividualAccess($individual, true); 565229eadeSGreg Roach 575229eadeSGreg Roach $title = $individual->fullName() . ' — ' . I18N::translate('Re-order names'); 585229eadeSGreg Roach 595229eadeSGreg Roach return $this->viewResponse('edit/reorder-names', [ 605229eadeSGreg Roach 'individual' => $individual, 615229eadeSGreg Roach 'title' => $title, 625229eadeSGreg Roach 'tree' => $tree, 635229eadeSGreg Roach ]); 645229eadeSGreg Roach } 655229eadeSGreg Roach} 66