xref: /webtrees/app/Http/RequestHandlers/SelectNewFact.php (revision d11be7027e34e3121be11cc025421873364403f9)
12917771cSGreg Roach<?php
22917771cSGreg Roach
32917771cSGreg Roach/**
42917771cSGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
62917771cSGreg Roach * This program is free software: you can redistribute it and/or modify
72917771cSGreg Roach * it under the terms of the GNU General Public License as published by
82917771cSGreg Roach * the Free Software Foundation, either version 3 of the License, or
92917771cSGreg Roach * (at your option) any later version.
102917771cSGreg Roach * This program is distributed in the hope that it will be useful,
112917771cSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
122917771cSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
132917771cSGreg Roach * GNU General Public License for more details.
142917771cSGreg 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/>.
162917771cSGreg Roach */
172917771cSGreg Roach
182917771cSGreg Roachdeclare(strict_types=1);
192917771cSGreg Roach
202917771cSGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
212917771cSGreg Roach
22b55cbc6bSGreg Roachuse Fisharebest\Webtrees\Validator;
232917771cSGreg Roachuse Psr\Http\Message\ResponseInterface;
242917771cSGreg Roachuse Psr\Http\Message\ServerRequestInterface;
252917771cSGreg Roachuse Psr\Http\Server\RequestHandlerInterface;
262917771cSGreg Roach
272917771cSGreg Roachuse function redirect;
282917771cSGreg Roach
292917771cSGreg Roach/**
302917771cSGreg Roach * Select a new fact to add.
312917771cSGreg Roach */
322917771cSGreg Roachclass SelectNewFact implements RequestHandlerInterface
332917771cSGreg Roach{
342917771cSGreg Roach    /**
352917771cSGreg Roach     * @param ServerRequestInterface $request
362917771cSGreg Roach     *
372917771cSGreg Roach     * @return ResponseInterface
382917771cSGreg Roach     */
392917771cSGreg Roach    public function handle(ServerRequestInterface $request): ResponseInterface
402917771cSGreg Roach    {
412917771cSGreg Roach        return redirect(route(AddNewFact::class, [
42748dbe15SGreg Roach            'tree' => Validator::attributes($request)->tree()->name(),
43748dbe15SGreg Roach            'xref' => Validator::attributes($request)->isXref()->string('xref'),
44748dbe15SGreg Roach            'fact' => Validator::parsedBody($request)->string('fact'),
452917771cSGreg Roach        ]));
462917771cSGreg Roach    }
472917771cSGreg Roach}
48