xref: /webtrees/app/Module/ModuleReportTrait.php (revision 962ead5100d09d236084c90178436e83af34e4b2)
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 */
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    /**
30*962ead51SGreg Roach     * @return string
31*962ead51SGreg Roach     */
32*962ead51SGreg Roach    abstract public function name(): string;
33*962ead51SGreg Roach
34*962ead51SGreg Roach    /**
359af6b024SGreg Roach     * Name of the XML report file, relative to the resources folder.
369af6b024SGreg Roach     *
379af6b024SGreg Roach     * @return string
389af6b024SGreg Roach     */
399af6b024SGreg Roach    public function xmlFilename(): string
409af6b024SGreg Roach    {
41aacc22caSGreg Roach        return 'xml/reports/' . $this->name() . '.xml';
429af6b024SGreg Roach    }
439af6b024SGreg Roach
449af6b024SGreg Roach
459af6b024SGreg Roach    /**
469af6b024SGreg Roach     * Return a menu item for this report.
479af6b024SGreg Roach     *
489af6b024SGreg Roach     * @param Individual $individual
499af6b024SGreg Roach     *
509af6b024SGreg Roach     * @return Menu
519af6b024SGreg Roach     */
529af6b024SGreg Roach    public function getReportMenu(Individual $individual): Menu
539af6b024SGreg Roach    {
549af6b024SGreg Roach        return new Menu(
559af6b024SGreg Roach            $this->title(),
569af6b024SGreg Roach            route('report-setup', [
579af6b024SGreg Roach                'xref'   => $individual->xref(),
58d72b284aSGreg Roach                'tree'   => $individual->tree()->name(),
599af6b024SGreg Roach                'report' => $this->name(),
609af6b024SGreg Roach            ]),
619af6b024SGreg Roach            'menu-report-' . $this->name(),
629af6b024SGreg Roach            ['rel' => 'nofollow']
639af6b024SGreg Roach        );
649af6b024SGreg Roach    }
6549a243cbSGreg Roach}
66