summaryrefslogtreecommitdiff
path: root/app/Http/RequestHandlers/SearchAdvancedAction.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-10-21 22:17:21 +0100
committerGreg Roach <fisharebest@webtrees.net>2019-10-21 22:17:21 +0100
commitf5402f3dbd759ec94d88460e5ae9815f9b823dae (patch)
tree706605025da9df793a3ba87b243cfa82a3dcac06 /app/Http/RequestHandlers/SearchAdvancedAction.php
parent2e4f3c66fd078618726ce0025d6766fed1a7d29a (diff)
downloadwebtrees-f5402f3dbd759ec94d88460e5ae9815f9b823dae.tar.gz
webtrees-f5402f3dbd759ec94d88460e5ae9815f9b823dae.tar.bz2
webtrees-f5402f3dbd759ec94d88460e5ae9815f9b823dae.zip
Fix: #2665 - Use POST+GET on search forms
Diffstat (limited to 'app/Http/RequestHandlers/SearchAdvancedAction.php')
-rw-r--r--app/Http/RequestHandlers/SearchAdvancedAction.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/app/Http/RequestHandlers/SearchAdvancedAction.php b/app/Http/RequestHandlers/SearchAdvancedAction.php
new file mode 100644
index 0000000000..539985156d
--- /dev/null
+++ b/app/Http/RequestHandlers/SearchAdvancedAction.php
@@ -0,0 +1,64 @@
+<?php
+
+/**
+ * webtrees: online genealogy
+ * Copyright (C) 2019 webtrees development team
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+declare(strict_types=1);
+
+namespace Fisharebest\Webtrees\Http\RequestHandlers;
+
+use Fisharebest\Webtrees\Tree;
+use InvalidArgumentException;
+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, new InvalidArgumentException());
+
+ $params = $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(),
+ ]));
+ }
+}