xref: /webtrees/app/Http/RequestHandlers/MessageSelect.php (revision d11be7027e34e3121be11cc025421873364403f9)
1e381f98dSGreg Roach<?php
2e381f98dSGreg Roach
3e381f98dSGreg Roach/**
4e381f98dSGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6e381f98dSGreg Roach * This program is free software: you can redistribute it and/or modify
7e381f98dSGreg Roach * it under the terms of the GNU General Public License as published by
8e381f98dSGreg Roach * the Free Software Foundation, either version 3 of the License, or
9e381f98dSGreg Roach * (at your option) any later version.
10e381f98dSGreg Roach * This program is distributed in the hope that it will be useful,
11e381f98dSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12e381f98dSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13e381f98dSGreg Roach * GNU General Public License for more details.
14e381f98dSGreg 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/>.
16e381f98dSGreg Roach */
17e381f98dSGreg Roach
18e381f98dSGreg Roachdeclare(strict_types=1);
19e381f98dSGreg Roach
20e381f98dSGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
21e381f98dSGreg Roach
22b55cbc6bSGreg Roachuse Fisharebest\Webtrees\Validator;
23e381f98dSGreg Roachuse Psr\Http\Message\ResponseInterface;
24e381f98dSGreg Roachuse Psr\Http\Message\ServerRequestInterface;
25e381f98dSGreg Roachuse Psr\Http\Server\RequestHandlerInterface;
26e381f98dSGreg Roach
27e381f98dSGreg Roach/**
28e381f98dSGreg Roach * Select a recipient for a message from a logged-in user.
29e381f98dSGreg Roach */
30e381f98dSGreg Roachclass MessageSelect implements RequestHandlerInterface
31e381f98dSGreg Roach{
32e381f98dSGreg Roach    /**
33e381f98dSGreg Roach     * @param ServerRequestInterface $request
34e381f98dSGreg Roach     *
35e381f98dSGreg Roach     * @return ResponseInterface
36e381f98dSGreg Roach     */
37e381f98dSGreg Roach    public function handle(ServerRequestInterface $request): ResponseInterface
38e381f98dSGreg Roach    {
39e381f98dSGreg Roach        return redirect(route(MessagePage::class, [
409f0bdfcdSGreg Roach            'body'    => Validator::parsedBody($request)->string('body', ''),
419f0bdfcdSGreg Roach            'subject' => Validator::parsedBody($request)->string('subject', ''),
429f0bdfcdSGreg Roach            'to'      => Validator::parsedBody($request)->string('to', ''),
439f0bdfcdSGreg Roach            'tree'    => Validator::attributes($request)->tree()->name(),
449f0bdfcdSGreg Roach            'url'     => Validator::parsedBody($request)->string('url', ''),
45e381f98dSGreg Roach        ]));
46e381f98dSGreg Roach    }
47e381f98dSGreg Roach}
48