xref: /webtrees/app/Module/ModuleReportTrait.php (revision 3976b4703df669696105ed6b024b96d433c8fbdb)
149a243cbSGreg Roach<?php
2*3976b470SGreg Roach
349a243cbSGreg Roach/**
449a243cbSGreg Roach * webtrees: online genealogy
549a243cbSGreg Roach * Copyright (C) 2019 webtrees development team
649a243cbSGreg Roach * This program is free software: you can redistribute it and/or modify
749a243cbSGreg Roach * it under the terms of the GNU General Public License as published by
849a243cbSGreg Roach * the Free Software Foundation, either version 3 of the License, or
949a243cbSGreg Roach * (at your option) any later version.
1049a243cbSGreg Roach * This program is distributed in the hope that it will be useful,
1149a243cbSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1249a243cbSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1349a243cbSGreg Roach * GNU General Public License for more details.
1449a243cbSGreg Roach * You should have received a copy of the GNU General Public License
1549a243cbSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
1649a243cbSGreg Roach */
1749a243cbSGreg Roachdeclare(strict_types=1);
1849a243cbSGreg Roach
1949a243cbSGreg Roachnamespace Fisharebest\Webtrees\Module;
2049a243cbSGreg Roach
219af6b024SGreg Roachuse Fisharebest\Webtrees\Individual;
229af6b024SGreg Roachuse Fisharebest\Webtrees\Menu;
239af6b024SGreg Roach
2449a243cbSGreg Roach/**
2549a243cbSGreg Roach * Trait ModuleReportTrait - default implementation of ModuleReportInterface
2649a243cbSGreg Roach */
2749a243cbSGreg Roachtrait ModuleReportTrait
2849a243cbSGreg Roach{
299af6b024SGreg Roach    /**
309af6b024SGreg Roach     * Name of the XML report file, relative to the resources folder.
319af6b024SGreg Roach     *
329af6b024SGreg Roach     * @return string
339af6b024SGreg Roach     */
349af6b024SGreg Roach    public function xmlFilename(): string
359af6b024SGreg Roach    {
36aacc22caSGreg Roach        return 'xml/reports/' . $this->name() . '.xml';
379af6b024SGreg Roach    }
389af6b024SGreg Roach
399af6b024SGreg Roach
409af6b024SGreg Roach    /**
419af6b024SGreg Roach     * Return a menu item for this report.
429af6b024SGreg Roach     *
439af6b024SGreg Roach     * @param Individual $individual
449af6b024SGreg Roach     *
459af6b024SGreg Roach     * @return Menu
469af6b024SGreg Roach     */
479af6b024SGreg Roach    public function getReportMenu(Individual $individual): Menu
489af6b024SGreg Roach    {
499af6b024SGreg Roach        return new Menu(
509af6b024SGreg Roach            $this->title(),
519af6b024SGreg Roach            route('report-setup', [
529af6b024SGreg Roach                'xref'   => $individual->xref(),
539af6b024SGreg Roach                'ged'    => $individual->tree()->name(),
549af6b024SGreg Roach                'report' => $this->name(),
559af6b024SGreg Roach            ]),
569af6b024SGreg Roach            'menu-report-' . $this->name(),
579af6b024SGreg Roach            ['rel' => 'nofollow']
589af6b024SGreg Roach        );
599af6b024SGreg Roach    }
6049a243cbSGreg Roach}
61