xref: /webtrees/app/Http/RequestHandlers/CalendarAction.php (revision 5bfc689774bb9a6401271c4ed15a6d50652c991b)
1b00cb080SGreg Roach<?php
2b00cb080SGreg Roach
3b00cb080SGreg Roach/**
4b00cb080SGreg Roach * webtrees: online genealogy
5*5bfc6897SGreg Roach * Copyright (C) 2022 webtrees development team
6b00cb080SGreg Roach * This program is free software: you can redistribute it and/or modify
7b00cb080SGreg Roach * it under the terms of the GNU General Public License as published by
8b00cb080SGreg Roach * the Free Software Foundation, either version 3 of the License, or
9b00cb080SGreg Roach * (at your option) any later version.
10b00cb080SGreg Roach * This program is distributed in the hope that it will be useful,
11b00cb080SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12b00cb080SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13b00cb080SGreg Roach * GNU General Public License for more details.
14b00cb080SGreg 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/>.
16b00cb080SGreg Roach */
17b00cb080SGreg Roach
18b00cb080SGreg Roachdeclare(strict_types=1);
19b00cb080SGreg Roach
20b00cb080SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
21b00cb080SGreg Roach
22b55cbc6bSGreg Roachuse Fisharebest\Webtrees\Validator;
23b00cb080SGreg Roachuse Psr\Http\Message\ResponseInterface;
24b00cb080SGreg Roachuse Psr\Http\Message\ServerRequestInterface;
25b00cb080SGreg Roachuse Psr\Http\Server\RequestHandlerInterface;
26b00cb080SGreg Roach
27b00cb080SGreg Roachuse function redirect;
28b00cb080SGreg Roachuse function route;
29b00cb080SGreg Roach
30b00cb080SGreg Roach/**
31b00cb080SGreg Roach * Show anniversaries for events in a given day/month/year.
32b00cb080SGreg Roach */
33b00cb080SGreg Roachclass CalendarAction implements RequestHandlerInterface
34b00cb080SGreg Roach{
35b00cb080SGreg Roach    /**
36b00cb080SGreg Roach     * @param ServerRequestInterface $request
37b00cb080SGreg Roach     *
38b00cb080SGreg Roach     * @return ResponseInterface
39b00cb080SGreg Roach     */
40b00cb080SGreg Roach    public function handle(ServerRequestInterface $request): ResponseInterface
41b00cb080SGreg Roach    {
42b55cbc6bSGreg Roach        $tree = Validator::attributes($request)->tree();
43b55cbc6bSGreg Roach        $view = Validator::attributes($request)->string('view');
44b00cb080SGreg Roach
45b00cb080SGreg Roach        $params = (array) $request->getParsedBody();
46b00cb080SGreg Roach
47b00cb080SGreg Roach        $params['tree'] = $tree->name();
48b00cb080SGreg Roach        $params['view'] = $view;
49b00cb080SGreg Roach
50b00cb080SGreg Roach        return redirect(route(CalendarPage::class, $params));
51b00cb080SGreg Roach    }
52b00cb080SGreg Roach}
53