xref: /webtrees/app/Http/RequestHandlers/CreateRepositoryModal.php (revision d11be7027e34e3121be11cc025421873364403f9)
1852ede8cSGreg Roach<?php
2852ede8cSGreg Roach
3852ede8cSGreg Roach/**
4852ede8cSGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6852ede8cSGreg Roach * This program is free software: you can redistribute it and/or modify
7852ede8cSGreg Roach * it under the terms of the GNU General Public License as published by
8852ede8cSGreg Roach * the Free Software Foundation, either version 3 of the License, or
9852ede8cSGreg Roach * (at your option) any later version.
10852ede8cSGreg Roach * This program is distributed in the hope that it will be useful,
11852ede8cSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12852ede8cSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13852ede8cSGreg Roach * GNU General Public License for more details.
14852ede8cSGreg 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/>.
16852ede8cSGreg Roach */
17852ede8cSGreg Roach
18852ede8cSGreg Roachdeclare(strict_types=1);
19852ede8cSGreg Roach
20852ede8cSGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
21852ede8cSGreg Roach
222d111ef4SGreg Roachuse Fisharebest\Webtrees\Elements\AddressLine;
232d111ef4SGreg Roachuse Fisharebest\Webtrees\Elements\AddressWebPage;
242d111ef4SGreg Roachuse Fisharebest\Webtrees\Elements\NameOfRepository;
252d111ef4SGreg Roachuse Fisharebest\Webtrees\I18N;
26b55cbc6bSGreg Roachuse Fisharebest\Webtrees\Validator;
27852ede8cSGreg Roachuse Psr\Http\Message\ResponseInterface;
28852ede8cSGreg Roachuse Psr\Http\Message\ServerRequestInterface;
29852ede8cSGreg Roachuse Psr\Http\Server\RequestHandlerInterface;
30852ede8cSGreg Roach
31d4265d07SGreg Roachuse function response;
32d4265d07SGreg Roachuse function view;
33852ede8cSGreg Roach
34852ede8cSGreg Roach/**
35852ede8cSGreg Roach * Show a form to create a new repository.
36852ede8cSGreg Roach */
37852ede8cSGreg Roachclass CreateRepositoryModal implements RequestHandlerInterface
38852ede8cSGreg Roach{
39852ede8cSGreg Roach    /**
40852ede8cSGreg Roach     * @param ServerRequestInterface $request
41852ede8cSGreg Roach     *
42852ede8cSGreg Roach     * @return ResponseInterface
43852ede8cSGreg Roach     */
44852ede8cSGreg Roach    public function handle(ServerRequestInterface $request): ResponseInterface
45852ede8cSGreg Roach    {
46b55cbc6bSGreg Roach        $tree = Validator::attributes($request)->tree();
47852ede8cSGreg Roach
482d111ef4SGreg Roach        $elements = [
492d111ef4SGreg Roach            'name'    => new NameOfRepository(I18N::translateContext('Repository', 'Name')),
502d111ef4SGreg Roach            'address' => new AddressLine(I18N::translate('Address')),
512d111ef4SGreg Roach            'url'     => new AddressWebPage(I18N::translate('URL')),
522d111ef4SGreg Roach        ];
532d111ef4SGreg Roach
54852ede8cSGreg Roach        return response(view('modals/create-repository', [
552d111ef4SGreg Roach            'elements' => $elements,
56852ede8cSGreg Roach            'tree'     => $tree,
57852ede8cSGreg Roach        ]));
58852ede8cSGreg Roach    }
59852ede8cSGreg Roach}
60