xref: /webtrees/app/Http/RequestHandlers/ExportGedcomPage.php (revision 89f7189b61a494347591c99bdb92afb7d8b66e1b)
16d576906SGreg Roach<?php
26d576906SGreg Roach
36d576906SGreg Roach/**
46d576906SGreg Roach * webtrees: online genealogy
5*89f7189bSGreg Roach * Copyright (C) 2021 webtrees development team
66d576906SGreg Roach * This program is free software: you can redistribute it and/or modify
76d576906SGreg Roach * it under the terms of the GNU General Public License as published by
86d576906SGreg Roach * the Free Software Foundation, either version 3 of the License, or
96d576906SGreg Roach * (at your option) any later version.
106d576906SGreg Roach * This program is distributed in the hope that it will be useful,
116d576906SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
126d576906SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
136d576906SGreg Roach * GNU General Public License for more details.
146d576906SGreg Roach * You should have received a copy of the GNU General Public License
15*89f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
166d576906SGreg Roach */
176d576906SGreg Roach
186d576906SGreg Roachdeclare(strict_types=1);
196d576906SGreg Roach
206d576906SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
216d576906SGreg Roach
226d576906SGreg Roachuse Fisharebest\Webtrees\Http\ViewResponseTrait;
236d576906SGreg Roachuse Fisharebest\Webtrees\I18N;
246d576906SGreg Roachuse Fisharebest\Webtrees\Tree;
256d576906SGreg Roachuse Psr\Http\Message\ResponseInterface;
266d576906SGreg Roachuse Psr\Http\Message\ServerRequestInterface;
276d576906SGreg Roachuse Psr\Http\Server\RequestHandlerInterface;
286d576906SGreg Roach
296d576906SGreg Roachuse function assert;
306d576906SGreg Roachuse function e;
316d576906SGreg Roach
326d576906SGreg Roach/**
336d576906SGreg Roach * Show download forms/optiosn.
346d576906SGreg Roach */
356d576906SGreg Roachclass ExportGedcomPage implements RequestHandlerInterface
366d576906SGreg Roach{
376d576906SGreg Roach    use ViewResponseTrait;
386d576906SGreg Roach
396d576906SGreg Roach    /**
406d576906SGreg Roach     * @param ServerRequestInterface $request
416d576906SGreg Roach     *
426d576906SGreg Roach     * @return ResponseInterface
436d576906SGreg Roach     */
446d576906SGreg Roach    public function handle(ServerRequestInterface $request): ResponseInterface
456d576906SGreg Roach    {
466d576906SGreg Roach        $tree = $request->getAttribute('tree');
476d576906SGreg Roach        assert($tree instanceof Tree);
486d576906SGreg Roach
496d576906SGreg Roach        $title = I18N::translate('Export a GEDCOM file') . ' — ' . e($tree->title());
506d576906SGreg Roach
516d576906SGreg Roach        $this->layout = 'layouts/administration';
526d576906SGreg Roach
536d576906SGreg Roach        return $this->viewResponse('admin/trees-export', [
546d576906SGreg Roach            'title' => $title,
556d576906SGreg Roach            'tree'  => $tree,
566d576906SGreg Roach        ]);
576d576906SGreg Roach    }
586d576906SGreg Roach}
59