1 | <?php |
||||
2 | |||||
3 | /** |
||||
4 | * webtrees: online genealogy |
||||
5 | * Copyright (C) 2025 webtrees development team |
||||
6 | * This program is free software: you can redistribute it and/or modify |
||||
7 | * it under the terms of the GNU General Public License as published by |
||||
8 | * the Free Software Foundation, either version 3 of the License, or |
||||
9 | * (at your option) any later version. |
||||
10 | * This program is distributed in the hope that it will be useful, |
||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
13 | * GNU General Public License for more details. |
||||
14 | * You should have received a copy of the GNU General Public License |
||||
15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
16 | */ |
||||
17 | |||||
18 | declare(strict_types=1); |
||||
19 | |||||
20 | namespace Fisharebest\Webtrees\Http\RequestHandlers; |
||||
21 | |||||
22 | use Fisharebest\Webtrees\Auth; |
||||
0 ignored issues
–
show
|
|||||
23 | use Fisharebest\Webtrees\Http\ViewResponseTrait; |
||||
24 | use Fisharebest\Webtrees\I18N; |
||||
0 ignored issues
–
show
The type
Fisharebest\Webtrees\I18N was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
25 | use Fisharebest\Webtrees\Log; |
||||
0 ignored issues
–
show
The type
Fisharebest\Webtrees\Log was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
26 | use Fisharebest\Webtrees\Services\SearchService; |
||||
0 ignored issues
–
show
The type
Fisharebest\Webtrees\Services\SearchService was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
27 | use Fisharebest\Webtrees\Services\TreeService; |
||||
0 ignored issues
–
show
The type
Fisharebest\Webtrees\Services\TreeService was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
28 | use Fisharebest\Webtrees\Site; |
||||
29 | use Fisharebest\Webtrees\Tree; |
||||
30 | use Fisharebest\Webtrees\Validator; |
||||
31 | use Illuminate\Support\Collection; |
||||
32 | use Psr\Http\Message\ResponseInterface; |
||||
33 | use Psr\Http\Message\ServerRequestInterface; |
||||
34 | use Psr\Http\Server\RequestHandlerInterface; |
||||
35 | |||||
36 | use function in_array; |
||||
37 | |||||
38 | /** |
||||
39 | * Search for (and optionally replace) genealogy data |
||||
40 | */ |
||||
41 | class SearchPhoneticPage implements RequestHandlerInterface |
||||
42 | { |
||||
43 | use ViewResponseTrait; |
||||
44 | |||||
45 | private SearchService $search_service; |
||||
46 | |||||
47 | private TreeService $tree_service; |
||||
48 | |||||
49 | /** |
||||
50 | * @param SearchService $search_service |
||||
51 | * @param TreeService $tree_service |
||||
52 | */ |
||||
53 | public function __construct(SearchService $search_service, TreeService $tree_service) |
||||
54 | { |
||||
55 | $this->search_service = $search_service; |
||||
56 | $this->tree_service = $tree_service; |
||||
57 | } |
||||
58 | |||||
59 | /** |
||||
60 | * The phonetic search. |
||||
61 | * |
||||
62 | * @param ServerRequestInterface $request |
||||
63 | * |
||||
64 | * @return ResponseInterface |
||||
65 | */ |
||||
66 | public function handle(ServerRequestInterface $request): ResponseInterface |
||||
67 | { |
||||
68 | $tree = Validator::attributes($request)->tree(); |
||||
69 | $firstname = Validator::queryParams($request)->string('firstname', ''); |
||||
70 | $lastname = Validator::queryParams($request)->string('lastname', ''); |
||||
71 | $place = Validator::queryParams($request)->string('place', ''); |
||||
72 | $soundex = Validator::queryParams($request)->isInArray(['DaitchM', 'Russell'])->string('soundex', 'Russell'); |
||||
73 | |||||
74 | // Where to search |
||||
75 | $search_tree_names = Validator::queryParams($request)->array('search_trees'); |
||||
76 | |||||
77 | // What trees to search? |
||||
78 | if (Site::getPreference('ALLOW_CHANGE_GEDCOM') === '1') { |
||||
79 | $all_trees = $this->tree_service->all(); |
||||
80 | } else { |
||||
81 | $all_trees = new Collection([$tree]); |
||||
0 ignored issues
–
show
array($tree) of type array<integer,Fisharebest\Webtrees\Tree> is incompatible with the type Illuminate\Contracts\Support\Arrayable expected by parameter $items of Illuminate\Support\Collection::__construct() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
82 | } |
||||
83 | |||||
84 | $search_trees = $all_trees |
||||
85 | ->filter(static fn (Tree $tree): bool => in_array($tree->name(), $search_tree_names, true)); |
||||
86 | |||||
87 | if ($search_trees->isEmpty()) { |
||||
88 | $search_trees->add($tree); |
||||
89 | } |
||||
90 | |||||
91 | $individuals = new Collection(); |
||||
92 | |||||
93 | if ($lastname !== '' || $firstname !== '' || $place !== '') { |
||||
94 | // Log search requests for visitors |
||||
95 | if (Auth::id() === null) { |
||||
96 | $message = 'Phonetic: first=' . $firstname . ', last=' . $lastname . ', place=' . $place; |
||||
97 | Log::addSearchLog($message, $search_trees->all()); |
||||
98 | } |
||||
99 | |||||
100 | $individuals = $this->search_service->searchIndividualsPhonetic($soundex, $lastname, $firstname, $place, $search_trees->all()); |
||||
101 | } |
||||
102 | |||||
103 | $title = I18N::translate('Phonetic search'); |
||||
104 | |||||
105 | return $this->viewResponse('search-phonetic-page', [ |
||||
106 | 'all_trees' => $all_trees, |
||||
107 | 'firstname' => $firstname, |
||||
108 | 'individuals' => $individuals, |
||||
109 | 'lastname' => $lastname, |
||||
110 | 'place' => $place, |
||||
111 | 'search_trees' => $search_trees, |
||||
112 | 'soundex' => $soundex, |
||||
113 | 'title' => $title, |
||||
114 | 'tree' => $tree, |
||||
115 | ]); |
||||
116 | } |
||||
117 | } |
||||
118 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths