xref: /webtrees/app/Module/FamilyGroupReportModule.php (revision d72b284a0846ca045e548a1c77ad11813bcbab92)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2019 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17declare(strict_types=1);
18
19namespace Fisharebest\Webtrees\Module;
20
21use Fisharebest\Webtrees\Family;
22use Fisharebest\Webtrees\I18N;
23use Fisharebest\Webtrees\Individual;
24use Fisharebest\Webtrees\Menu;
25
26/**
27 * Class FamilyGroupReportModule
28 */
29class FamilyGroupReportModule extends AbstractModule implements ModuleReportInterface
30{
31    use ModuleReportTrait;
32
33    /**
34     * How should this module be identified in the control panel, etc.?
35     *
36     * @return string
37     */
38    public function title(): string
39    {
40        // This text also appears in the .XML file - update both together
41        /* I18N: Name of a module/report */
42        return I18N::translate('Family');
43    }
44
45    /**
46     * A sentence describing what this module does.
47     *
48     * @return string
49     */
50    public function description(): string
51    {
52        // This text also appears in the .XML file - update both together
53        /* I18N: Description of the “Family” module */
54        return I18N::translate('A report of family members and their details.');
55    }
56
57    /**
58     * Return a menu item for this report.
59     *
60     * @param Individual $individual
61     *
62     * @return Menu
63     */
64    public function getReportMenu(Individual $individual): Menu
65    {
66        $family = $individual->spouseFamilies()->first() ?? $individual->childFamilies();
67        $xref   = $family instanceof Family ? $family->xref() : '';
68
69        return new Menu(
70            $this->title(),
71            route('report-setup', [
72                'tree'   => $individual->tree()->name(),
73                'xref'   => $xref,
74                'report' => $this->name(),
75            ]),
76            'menu-report-' . $this->name(),
77            ['rel' => 'nofollow']
78        );
79    }
80}
81