xref: /webtrees/app/Http/RequestHandlers/CalendarAction.php (revision d11be7027e34e3121be11cc025421873364403f9)
1b00cb080SGreg Roach<?php
2b00cb080SGreg Roach
3b00cb080SGreg Roach/**
4b00cb080SGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 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    {
42748dbe15SGreg Roach        return redirect(route(CalendarPage::class, [
43748dbe15SGreg Roach            'tree'     => Validator::attributes($request)->tree()->name(),
44748dbe15SGreg Roach            'view'     => Validator::attributes($request)->isInArray(['day', 'month', 'year'])->string('view'),
45748dbe15SGreg Roach            'cal'      => Validator::parsedBody($request)->string('cal'),
46748dbe15SGreg Roach            'day'      => Validator::parsedBody($request)->integer('day'),
47748dbe15SGreg Roach            'month'    => Validator::parsedBody($request)->string('month'),
48748dbe15SGreg Roach            'year'     => Validator::parsedBody($request)->integer('year'),
49748dbe15SGreg Roach            'filterev' => Validator::parsedBody($request)->string('filterev'),
50748dbe15SGreg Roach            'filterof' => Validator::parsedBody($request)->string('filterof'),
51748dbe15SGreg Roach            'filtersx' => Validator::parsedBody($request)->string('filtersx'),
52748dbe15SGreg Roach        ]));
53b00cb080SGreg Roach    }
54b00cb080SGreg Roach}
55