xref: /webtrees/app/Module/ModuleReportTrait.php (revision b9de055cd6bd86ffb2cab2e97fc2e86a302a4a43)
149a243cbSGreg Roach<?php
23976b470SGreg 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 */
17fcfa147eSGreg Roach
1849a243cbSGreg Roachdeclare(strict_types=1);
1949a243cbSGreg Roach
2049a243cbSGreg Roachnamespace Fisharebest\Webtrees\Module;
2149a243cbSGreg Roach
229af6b024SGreg Roachuse Fisharebest\Webtrees\Individual;
239af6b024SGreg Roachuse Fisharebest\Webtrees\Menu;
249af6b024SGreg Roach
2549a243cbSGreg Roach/**
2649a243cbSGreg Roach * Trait ModuleReportTrait - default implementation of ModuleReportInterface
2749a243cbSGreg Roach */
2849a243cbSGreg Roachtrait ModuleReportTrait
2949a243cbSGreg Roach{
309af6b024SGreg Roach    /**
31962ead51SGreg Roach     * @return string
32962ead51SGreg Roach     */
33962ead51SGreg Roach    abstract public function name(): string;
34962ead51SGreg Roach
35962ead51SGreg Roach    /**
36*b9de055cSGreg Roach     * @return string
37*b9de055cSGreg Roach     */
38*b9de055cSGreg Roach    abstract public function title(): string;
39*b9de055cSGreg Roach
40*b9de055cSGreg Roach    /**
419af6b024SGreg Roach     * Name of the XML report file, relative to the resources folder.
429af6b024SGreg Roach     *
439af6b024SGreg Roach     * @return string
449af6b024SGreg Roach     */
459af6b024SGreg Roach    public function xmlFilename(): string
469af6b024SGreg Roach    {
47aacc22caSGreg Roach        return 'xml/reports/' . $this->name() . '.xml';
489af6b024SGreg Roach    }
499af6b024SGreg Roach
509af6b024SGreg Roach
519af6b024SGreg Roach    /**
529af6b024SGreg Roach     * Return a menu item for this report.
539af6b024SGreg Roach     *
549af6b024SGreg Roach     * @param Individual $individual
559af6b024SGreg Roach     *
569af6b024SGreg Roach     * @return Menu
579af6b024SGreg Roach     */
589af6b024SGreg Roach    public function getReportMenu(Individual $individual): Menu
599af6b024SGreg Roach    {
609af6b024SGreg Roach        return new Menu(
619af6b024SGreg Roach            $this->title(),
629af6b024SGreg Roach            route('report-setup', [
639af6b024SGreg Roach                'xref'   => $individual->xref(),
64d72b284aSGreg Roach                'tree'   => $individual->tree()->name(),
659af6b024SGreg Roach                'report' => $this->name(),
669af6b024SGreg Roach            ]),
679af6b024SGreg Roach            'menu-report-' . $this->name(),
689af6b024SGreg Roach            ['rel' => 'nofollow']
699af6b024SGreg Roach        );
709af6b024SGreg Roach    }
7149a243cbSGreg Roach}
72