18c2e8227SGreg Roach<?php 23976b470SGreg Roach 38c2e8227SGreg Roach/** 48c2e8227SGreg Roach * webtrees: online genealogy 5*d11be702SGreg Roach * Copyright (C) 2023 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 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 168c2e8227SGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 2076692c8bSGreg Roachnamespace Fisharebest\Webtrees\Module; 2176692c8bSGreg Roach 22c0e0c66dSGreg Roachuse Fisharebest\Webtrees\Family; 231cfe16bdSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ReportSetupPage; 240e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N; 252c2c92e6SGreg Roachuse Fisharebest\Webtrees\Individual; 260e62c4b8SGreg Roachuse Fisharebest\Webtrees\Menu; 278c2e8227SGreg Roach 288c2e8227SGreg Roach/** 298c2e8227SGreg Roach * Class FamilyGroupReportModule 308c2e8227SGreg Roach */ 3137eb8894SGreg Roachclass FamilyGroupReportModule extends AbstractModule implements ModuleReportInterface 32c1010edaSGreg Roach{ 3349a243cbSGreg Roach use ModuleReportTrait; 3449a243cbSGreg Roach 35961ec755SGreg Roach /** 360cfd6963SGreg Roach * How should this module be identified in the control panel, etc.? 37961ec755SGreg Roach * 38961ec755SGreg Roach * @return string 39961ec755SGreg Roach */ 4049a243cbSGreg Roach public function title(): string 41c1010edaSGreg Roach { 428c2e8227SGreg Roach // This text also appears in the .XML file - update both together 43bbb76c12SGreg Roach /* I18N: Name of a module/report */ 44bbb76c12SGreg Roach return I18N::translate('Family'); 458c2e8227SGreg Roach } 468c2e8227SGreg Roach 47961ec755SGreg Roach /** 48961ec755SGreg Roach * A sentence describing what this module does. 49961ec755SGreg Roach * 50961ec755SGreg Roach * @return string 51961ec755SGreg Roach */ 5249a243cbSGreg Roach public function description(): string 53c1010edaSGreg Roach { 548c2e8227SGreg Roach // This text also appears in the .XML file - update both together 55bbb76c12SGreg Roach /* I18N: Description of the “Family” module */ 56bbb76c12SGreg Roach return I18N::translate('A report of family members and their details.'); 578c2e8227SGreg Roach } 588c2e8227SGreg Roach 590ee13198SGreg Roach /** 600ee13198SGreg Roach * Return a menu item for this report. 610ee13198SGreg Roach * 6282ea510dSGreg Roach * @param Individual $individual 63dc809433SGreg Roach * 640ee13198SGreg Roach * @return Menu 650ee13198SGreg Roach */ 662c2c92e6SGreg Roach public function getReportMenu(Individual $individual): Menu 67c1010edaSGreg Roach { 68c0e0c66dSGreg Roach $family = $individual->spouseFamilies()->first() ?? $individual->childFamilies(); 69c0e0c66dSGreg Roach $xref = $family instanceof Family ? $family->xref() : ''; 70c0e0c66dSGreg Roach 710ee13198SGreg Roach return new Menu( 7249a243cbSGreg Roach $this->title(), 731cfe16bdSGreg Roach route(ReportSetupPage::class, [ 74d72b284aSGreg Roach 'tree' => $individual->tree()->name(), 75c0e0c66dSGreg Roach 'xref' => $xref, 7626684e68SGreg Roach 'report' => $this->name(), 77c1010edaSGreg Roach ]), 7826684e68SGreg Roach 'menu-report-' . $this->name(), 7913abd6f3SGreg Roach ['rel' => 'nofollow'] 808c2e8227SGreg Roach ); 818c2e8227SGreg Roach } 828c2e8227SGreg Roach} 83