xref: /webtrees/app/Http/RequestHandlers/UnconnectedAction.php (revision 89f7189b61a494347591c99bdb92afb7d8b66e1b)
196716c47SGreg Roach<?php
296716c47SGreg Roach
396716c47SGreg Roach/**
496716c47SGreg Roach * webtrees: online genealogy
5*89f7189bSGreg Roach * Copyright (C) 2021 webtrees development team
696716c47SGreg Roach * This program is free software: you can redistribute it and/or modify
796716c47SGreg Roach * it under the terms of the GNU General Public License as published by
896716c47SGreg Roach * the Free Software Foundation, either version 3 of the License, or
996716c47SGreg Roach * (at your option) any later version.
1096716c47SGreg Roach * This program is distributed in the hope that it will be useful,
1196716c47SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1296716c47SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1396716c47SGreg Roach * GNU General Public License for more details.
1496716c47SGreg Roach * You should have received a copy of the GNU General Public License
15*89f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
1696716c47SGreg Roach */
1796716c47SGreg Roach
1896716c47SGreg Roachdeclare(strict_types=1);
1996716c47SGreg Roach
2096716c47SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
2196716c47SGreg Roach
2296716c47SGreg Roachuse Fisharebest\Webtrees\Tree;
2396716c47SGreg Roachuse Psr\Http\Message\ResponseInterface;
2496716c47SGreg Roachuse Psr\Http\Message\ServerRequestInterface;
2596716c47SGreg Roachuse Psr\Http\Server\RequestHandlerInterface;
2696716c47SGreg Roach
2796716c47SGreg Roachuse function assert;
2896716c47SGreg Roach
2996716c47SGreg Roach/**
3096716c47SGreg Roach * Find groups of unrelated individuals.
3196716c47SGreg Roach */
3296716c47SGreg Roachclass UnconnectedAction implements RequestHandlerInterface
3396716c47SGreg Roach{
3496716c47SGreg Roach    /** @var string */
3596716c47SGreg Roach    protected $layout = 'layouts/administration';
3696716c47SGreg Roach
3796716c47SGreg Roach    /**
3896716c47SGreg Roach     * @param ServerRequestInterface $request
3996716c47SGreg Roach     *
4096716c47SGreg Roach     * @return ResponseInterface
4196716c47SGreg Roach     */
4296716c47SGreg Roach    public function handle(ServerRequestInterface $request): ResponseInterface
4396716c47SGreg Roach    {
4496716c47SGreg Roach        $tree = $request->getAttribute('tree');
4596716c47SGreg Roach        assert($tree instanceof Tree);
4696716c47SGreg Roach
47b46c87bdSGreg Roach        $params = (array) $request->getParsedBody();
48b46c87bdSGreg Roach
49f925fcc4SGreg Roach        $aliases    = $params['aliases'] ?? '';
50b46c87bdSGreg Roach        $associates = $params['associates'] ?? '';
5196716c47SGreg Roach
52f925fcc4SGreg Roach        return redirect(route(UnconnectedPage::class, [
53f925fcc4SGreg Roach            'aliases'    => $aliases,
54f925fcc4SGreg Roach            'associates' => $associates,
55f925fcc4SGreg Roach            'tree'       => $tree->name(),
56f925fcc4SGreg Roach        ]));
5796716c47SGreg Roach    }
5896716c47SGreg Roach}
59