xref: /webtrees/app/Module/FamilyGroupReportModule.php (revision 3976b4703df669696105ed6b024b96d433c8fbdb)
18c2e8227SGreg Roach<?php
2*3976b470SGreg Roach
38c2e8227SGreg Roach/**
48c2e8227SGreg Roach * webtrees: online genealogy
58fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team
68c2e8227SGreg Roach * This program is free software: you can redistribute it and/or modify
78c2e8227SGreg Roach * it under the terms of the GNU General Public License as published by
88c2e8227SGreg Roach * the Free Software Foundation, either version 3 of the License, or
98c2e8227SGreg Roach * (at your option) any later version.
108c2e8227SGreg Roach * This program is distributed in the hope that it will be useful,
118c2e8227SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
128c2e8227SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
138c2e8227SGreg Roach * GNU General Public License for more details.
148c2e8227SGreg Roach * You should have received a copy of the GNU General Public License
158c2e8227SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
168c2e8227SGreg Roach */
17e7f56f2aSGreg Roachdeclare(strict_types=1);
18e7f56f2aSGreg Roach
1976692c8bSGreg Roachnamespace Fisharebest\Webtrees\Module;
2076692c8bSGreg Roach
21c0e0c66dSGreg Roachuse Fisharebest\Webtrees\Family;
220e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N;
232c2c92e6SGreg Roachuse Fisharebest\Webtrees\Individual;
240e62c4b8SGreg Roachuse Fisharebest\Webtrees\Menu;
258c2e8227SGreg Roach
268c2e8227SGreg Roach/**
278c2e8227SGreg Roach * Class FamilyGroupReportModule
288c2e8227SGreg Roach */
2937eb8894SGreg Roachclass FamilyGroupReportModule extends AbstractModule implements ModuleReportInterface
30c1010edaSGreg Roach{
3149a243cbSGreg Roach    use ModuleReportTrait;
3249a243cbSGreg Roach
33961ec755SGreg Roach    /**
340cfd6963SGreg Roach     * How should this module be identified in the control panel, etc.?
35961ec755SGreg Roach     *
36961ec755SGreg Roach     * @return string
37961ec755SGreg Roach     */
3849a243cbSGreg Roach    public function title(): string
39c1010edaSGreg Roach    {
408c2e8227SGreg Roach        // This text also appears in the .XML file - update both together
41bbb76c12SGreg Roach        /* I18N: Name of a module/report */
42bbb76c12SGreg Roach        return I18N::translate('Family');
438c2e8227SGreg Roach    }
448c2e8227SGreg Roach
45961ec755SGreg Roach    /**
46961ec755SGreg Roach     * A sentence describing what this module does.
47961ec755SGreg Roach     *
48961ec755SGreg Roach     * @return string
49961ec755SGreg Roach     */
5049a243cbSGreg Roach    public function description(): string
51c1010edaSGreg Roach    {
528c2e8227SGreg Roach        // This text also appears in the .XML file - update both together
53bbb76c12SGreg Roach        /* I18N: Description of the “Family” module */
54bbb76c12SGreg Roach        return I18N::translate('A report of family members and their details.');
558c2e8227SGreg Roach    }
568c2e8227SGreg Roach
570ee13198SGreg Roach    /**
580ee13198SGreg Roach     * Return a menu item for this report.
590ee13198SGreg Roach     *
6082ea510dSGreg Roach     * @param Individual $individual
61dc809433SGreg Roach     *
620ee13198SGreg Roach     * @return Menu
630ee13198SGreg Roach     */
642c2c92e6SGreg Roach    public function getReportMenu(Individual $individual): Menu
65c1010edaSGreg Roach    {
66c0e0c66dSGreg Roach        $family = $individual->spouseFamilies()->first() ?? $individual->childFamilies();
67c0e0c66dSGreg Roach        $xref   = $family instanceof Family ? $family->xref() : '';
68c0e0c66dSGreg Roach
690ee13198SGreg Roach        return new Menu(
7049a243cbSGreg Roach            $this->title(),
712c2c92e6SGreg Roach            route('report-setup', [
722c2c92e6SGreg Roach                'ged'    => $individual->tree()->name(),
73c0e0c66dSGreg Roach                'xref'   => $xref,
7426684e68SGreg Roach                'report' => $this->name(),
75c1010edaSGreg Roach            ]),
7626684e68SGreg Roach            'menu-report-' . $this->name(),
7713abd6f3SGreg Roach            ['rel' => 'nofollow']
788c2e8227SGreg Roach        );
798c2e8227SGreg Roach    }
808c2e8227SGreg Roach}
81