. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fisharebest\Webtrees\Tree; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function assert; /** * Search for genealogy data */ class SearchAdvancedAction implements RequestHandlerInterface { /** * The standard search. * * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $tree = $request->getAttribute('tree'); assert($tree instanceof Tree); $params = (array) $request->getParsedBody(); $fields = $params['fields'] ?? []; $modifiers = $params['modifiers'] ?? []; $other_field = $params['other_field'] ?? ''; $other_value = $params['other_value'] ?? ''; if ($other_field !== '' && $other_value !== '') { $fields[$other_field] = $other_value; } return redirect(route(SearchAdvancedPage::class, [ 'fields' => $fields, 'modifiers' => $modifiers, 'tree' => $tree->name(), ])); } }