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 4749a243cbSGreg Roach public function description(): string 48c1010edaSGreg Roach { 498c2e8227SGreg Roach // This text also appears in the .XML file - update both together 50bbb76c12SGreg Roach /* I18N: Description of the “Family” module */ 51bbb76c12SGreg Roach return I18N::translate('A report of family members and their details.'); 528c2e8227SGreg Roach } 538c2e8227SGreg Roach 540ee13198SGreg Roach /** 550ee13198SGreg Roach * Return a menu item for this report. 560ee13198SGreg Roach * 5782ea510dSGreg Roach * @param Individual $individual 58dc809433SGreg Roach * 590ee13198SGreg Roach * @return Menu 600ee13198SGreg Roach */ 612c2c92e6SGreg Roach public function getReportMenu(Individual $individual): Menu 62c1010edaSGreg Roach { 63c0e0c66dSGreg Roach $family = $individual->spouseFamilies()->first() ?? $individual->childFamilies(); 64c0e0c66dSGreg Roach $xref = $family instanceof Family ? $family->xref() : ''; 65c0e0c66dSGreg Roach 660ee13198SGreg Roach return new Menu( 6749a243cbSGreg Roach $this->title(), 681cfe16bdSGreg Roach route(ReportSetupPage::class, [ 69d72b284aSGreg Roach 'tree' => $individual->tree()->name(), 70c0e0c66dSGreg Roach 'xref' => $xref, 7126684e68SGreg Roach 'report' => $this->name(), 72c1010edaSGreg Roach ]), 7326684e68SGreg Roach 'menu-report-' . $this->name(), 7413abd6f3SGreg Roach ['rel' => 'nofollow'] 758c2e8227SGreg Roach ); 768c2e8227SGreg Roach } 778c2e8227SGreg Roach} 78