163763244SGreg Roach<?php 263763244SGreg Roach 363763244SGreg Roach/** 463763244SGreg Roach * webtrees: online genealogy 55bfc6897SGreg Roach * Copyright (C) 2022 webtrees development team 663763244SGreg Roach * This program is free software: you can redistribute it and/or modify 763763244SGreg Roach * it under the terms of the GNU General Public License as published by 863763244SGreg Roach * the Free Software Foundation, either version 3 of the License, or 963763244SGreg Roach * (at your option) any later version. 1063763244SGreg Roach * This program is distributed in the hope that it will be useful, 1163763244SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1263763244SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1363763244SGreg Roach * GNU General Public License for more details. 1463763244SGreg 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/>. 1663763244SGreg Roach */ 1763763244SGreg Roach 1863763244SGreg Roachdeclare(strict_types=1); 1963763244SGreg Roach 2063763244SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers; 2163763244SGreg Roach 22b55cbc6bSGreg Roachuse Fisharebest\Webtrees\Validator; 2363763244SGreg Roachuse Illuminate\Support\Collection; 2463763244SGreg Roachuse Psr\Http\Message\ServerRequestInterface; 2563763244SGreg Roach 2663763244SGreg Roach/** 2763763244SGreg Roach * Autocomplete handler for surnames 2863763244SGreg Roach */ 2963763244SGreg Roachclass AutoCompleteSurname extends AbstractAutocompleteHandler 3063763244SGreg Roach{ 31928b8592SGreg Roach /** 32928b8592SGreg Roach * @param ServerRequestInterface $request 33928b8592SGreg Roach * 3436779af1SGreg Roach * @return Collection<int,string> 35928b8592SGreg Roach */ 3663763244SGreg Roach protected function search(ServerRequestInterface $request): Collection 3763763244SGreg Roach { 38b55cbc6bSGreg Roach $tree = Validator::attributes($request)->tree(); 39*bb5c0006SGreg Roach $query = Validator::queryParams($request)->string('query'); 4063763244SGreg Roach 4163763244SGreg Roach return $this->search_service 4263763244SGreg Roach ->searchSurnames([$tree], [$query], 0, static::LIMIT); 4363763244SGreg Roach } 4463763244SGreg Roach} 45