1*f5402f3dSGreg Roach<?php 2*f5402f3dSGreg Roach 3*f5402f3dSGreg Roach/** 4*f5402f3dSGreg Roach * webtrees: online genealogy 5*f5402f3dSGreg Roach * Copyright (C) 2019 webtrees development team 6*f5402f3dSGreg Roach * This program is free software: you can redistribute it and/or modify 7*f5402f3dSGreg Roach * it under the terms of the GNU General Public License as published by 8*f5402f3dSGreg Roach * the Free Software Foundation, either version 3 of the License, or 9*f5402f3dSGreg Roach * (at your option) any later version. 10*f5402f3dSGreg Roach * This program is distributed in the hope that it will be useful, 11*f5402f3dSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12*f5402f3dSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*f5402f3dSGreg Roach * GNU General Public License for more details. 14*f5402f3dSGreg Roach * You should have received a copy of the GNU General Public License 15*f5402f3dSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 16*f5402f3dSGreg Roach */ 17*f5402f3dSGreg Roach 18*f5402f3dSGreg Roachdeclare(strict_types=1); 19*f5402f3dSGreg Roach 20*f5402f3dSGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers; 21*f5402f3dSGreg Roach 22*f5402f3dSGreg Roachuse Fisharebest\Webtrees\Tree; 23*f5402f3dSGreg Roachuse InvalidArgumentException; 24*f5402f3dSGreg Roachuse Psr\Http\Message\ResponseInterface; 25*f5402f3dSGreg Roachuse Psr\Http\Message\ServerRequestInterface; 26*f5402f3dSGreg Roachuse Psr\Http\Server\RequestHandlerInterface; 27*f5402f3dSGreg Roach 28*f5402f3dSGreg Roachuse function assert; 29*f5402f3dSGreg Roach 30*f5402f3dSGreg Roach/** 31*f5402f3dSGreg Roach * Search for genealogy data 32*f5402f3dSGreg Roach */ 33*f5402f3dSGreg Roachclass SearchPhoneticAction implements RequestHandlerInterface 34*f5402f3dSGreg Roach{ 35*f5402f3dSGreg Roach /** 36*f5402f3dSGreg Roach * The standard search. 37*f5402f3dSGreg Roach * 38*f5402f3dSGreg Roach * @param ServerRequestInterface $request 39*f5402f3dSGreg Roach * 40*f5402f3dSGreg Roach * @return ResponseInterface 41*f5402f3dSGreg Roach */ 42*f5402f3dSGreg Roach public function handle(ServerRequestInterface $request): ResponseInterface 43*f5402f3dSGreg Roach { 44*f5402f3dSGreg Roach $tree = $request->getAttribute('tree'); 45*f5402f3dSGreg Roach assert($tree instanceof Tree, new InvalidArgumentException()); 46*f5402f3dSGreg Roach 47*f5402f3dSGreg Roach $params = $request->getParsedBody(); 48*f5402f3dSGreg Roach 49*f5402f3dSGreg Roach return redirect(route(SearchPhoneticPage::class, [ 50*f5402f3dSGreg Roach 'firstname' => $params['firstname'] ?? '', 51*f5402f3dSGreg Roach 'lastname' => $params['lastname'] ?? '', 52*f5402f3dSGreg Roach 'place' => $params['place'] ?? '', 53*f5402f3dSGreg Roach 'soundex' => $params['soundex'] ?? 'Russell', 54*f5402f3dSGreg Roach 'tree' => $tree->name(), 55*f5402f3dSGreg Roach ])); 56*f5402f3dSGreg Roach } 57*f5402f3dSGreg Roach} 58