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