xref: /webtrees/app/Module/ModuleReportTrait.php (revision 9af6b024736711ef85eba12979344b0241b8b348)
149a243cbSGreg Roach<?php
249a243cbSGreg Roach/**
349a243cbSGreg Roach * webtrees: online genealogy
449a243cbSGreg Roach * Copyright (C) 2019 webtrees development team
549a243cbSGreg Roach * This program is free software: you can redistribute it and/or modify
649a243cbSGreg Roach * it under the terms of the GNU General Public License as published by
749a243cbSGreg Roach * the Free Software Foundation, either version 3 of the License, or
849a243cbSGreg Roach * (at your option) any later version.
949a243cbSGreg Roach * This program is distributed in the hope that it will be useful,
1049a243cbSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1149a243cbSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1249a243cbSGreg Roach * GNU General Public License for more details.
1349a243cbSGreg Roach * You should have received a copy of the GNU General Public License
1449a243cbSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
1549a243cbSGreg Roach */
1649a243cbSGreg Roachdeclare(strict_types=1);
1749a243cbSGreg Roach
1849a243cbSGreg Roachnamespace Fisharebest\Webtrees\Module;
1949a243cbSGreg Roach
20*9af6b024SGreg Roachuse Fisharebest\Webtrees\Individual;
21*9af6b024SGreg Roachuse Fisharebest\Webtrees\Menu;
22*9af6b024SGreg Roach
2349a243cbSGreg Roach/**
2449a243cbSGreg Roach * Trait ModuleReportTrait - default implementation of ModuleReportInterface
2549a243cbSGreg Roach */
2649a243cbSGreg Roachtrait ModuleReportTrait
2749a243cbSGreg Roach{
28*9af6b024SGreg Roach    /**
29*9af6b024SGreg Roach     * Name of the XML report file, relative to the resources folder.
30*9af6b024SGreg Roach     *
31*9af6b024SGreg Roach     * @return string
32*9af6b024SGreg Roach     */
33*9af6b024SGreg Roach    public function xmlFilename(): string
34*9af6b024SGreg Roach    {
35*9af6b024SGreg Roach        return $this->resourcesFolder() . 'xml/reports/' . $this->name() . '.xml';
36*9af6b024SGreg Roach    }
37*9af6b024SGreg Roach
38*9af6b024SGreg Roach
39*9af6b024SGreg Roach    /**
40*9af6b024SGreg Roach     * Return a menu item for this report.
41*9af6b024SGreg Roach     *
42*9af6b024SGreg Roach     * @param Individual $individual
43*9af6b024SGreg Roach     *
44*9af6b024SGreg Roach     * @return Menu
45*9af6b024SGreg Roach     */
46*9af6b024SGreg Roach    public function getReportMenu(Individual $individual): Menu
47*9af6b024SGreg Roach    {
48*9af6b024SGreg Roach        return new Menu(
49*9af6b024SGreg Roach            $this->title(),
50*9af6b024SGreg Roach            route('report-setup', [
51*9af6b024SGreg Roach                'xref'   => $individual->xref(),
52*9af6b024SGreg Roach                'ged'    => $individual->tree()->name(),
53*9af6b024SGreg Roach                'report' => $this->name(),
54*9af6b024SGreg Roach            ]),
55*9af6b024SGreg Roach            'menu-report-' . $this->name(),
56*9af6b024SGreg Roach            ['rel' => 'nofollow']
57*9af6b024SGreg Roach        );
58*9af6b024SGreg Roach    }
5949a243cbSGreg Roach}
60