167992b6aSRichard Cissee<?php 267992b6aSRichard Cissee/** 367992b6aSRichard Cissee * webtrees: online genealogy 467992b6aSRichard Cissee * Copyright (C) 2019 webtrees development team 567992b6aSRichard Cissee * This program is free software: you can redistribute it and/or modify 667992b6aSRichard Cissee * it under the terms of the GNU General Public License as published by 767992b6aSRichard Cissee * the Free Software Foundation, either version 3 of the License, or 867992b6aSRichard Cissee * (at your option) any later version. 967992b6aSRichard Cissee * This program is distributed in the hope that it will be useful, 1067992b6aSRichard Cissee * but WITHOUT ANY WARRANTY; without even the implied warranty of 1167992b6aSRichard Cissee * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1267992b6aSRichard Cissee * GNU General Public License for more details. 1367992b6aSRichard Cissee * You should have received a copy of the GNU General Public License 1467992b6aSRichard Cissee * along with this program. If not, see <http://www.gnu.org/licenses/>. 1567992b6aSRichard Cissee */ 1667992b6aSRichard Cisseedeclare(strict_types=1); 1767992b6aSRichard Cissee 1867992b6aSRichard Cisseenamespace Fisharebest\Webtrees\Module; 1967992b6aSRichard Cissee 2067992b6aSRichard Cisseeuse Fisharebest\Webtrees\Contracts\UserInterface; 2167992b6aSRichard Cisseeuse Fisharebest\Webtrees\Http\Controllers\BranchesController; 2267992b6aSRichard Cisseeuse Fisharebest\Webtrees\I18N; 2367992b6aSRichard Cisseeuse Fisharebest\Webtrees\Services\ModuleService; 2467992b6aSRichard Cisseeuse Fisharebest\Webtrees\Tree; 2567992b6aSRichard Cisseeuse Fisharebest\Webtrees\Auth; 266ccdf4f0SGreg Roachuse Psr\Http\Message\ResponseInterface; 276ccdf4f0SGreg Roachuse Psr\Http\Message\ServerRequestInterface; 2867992b6aSRichard Cissee 2967992b6aSRichard Cissee/** 3067992b6aSRichard Cissee * Class BranchesListModule 3167992b6aSRichard Cissee */ 3267992b6aSRichard Cisseeclass BranchesListModule extends AbstractModule implements ModuleListInterface 3367992b6aSRichard Cissee{ 3467992b6aSRichard Cissee use ModuleListTrait; 3567992b6aSRichard Cissee 3667992b6aSRichard Cissee /** 370cfd6963SGreg Roach * How should this module be identified in the control panel, etc.? 3867992b6aSRichard Cissee * 3967992b6aSRichard Cissee * @return string 4067992b6aSRichard Cissee */ 4167992b6aSRichard Cissee public function title(): string 4267992b6aSRichard Cissee { 4367992b6aSRichard Cissee /* I18N: Name of a module/list */ 4467992b6aSRichard Cissee return I18N::translate('Branches'); 4567992b6aSRichard Cissee } 4667992b6aSRichard Cissee 4767992b6aSRichard Cissee /** 4867992b6aSRichard Cissee * A sentence describing what this module does. 4967992b6aSRichard Cissee * 5067992b6aSRichard Cissee * @return string 5167992b6aSRichard Cissee */ 5267992b6aSRichard Cissee public function description(): string 5367992b6aSRichard Cissee { 5467992b6aSRichard Cissee /* I18N: Description of the “BranchesListModule” module */ 5567992b6aSRichard Cissee return I18N::translate('A list of branches of a family.'); 5667992b6aSRichard Cissee } 5767992b6aSRichard Cissee 5867992b6aSRichard Cissee /** 5967992b6aSRichard Cissee * CSS class for the URL. 6067992b6aSRichard Cissee * 6167992b6aSRichard Cissee * @return string 6267992b6aSRichard Cissee */ 6367992b6aSRichard Cissee public function listMenuClass(): string 6467992b6aSRichard Cissee { 6567992b6aSRichard Cissee return 'menu-branches'; 6667992b6aSRichard Cissee } 6767992b6aSRichard Cissee 684db4b4a9SGreg Roach /** 694db4b4a9SGreg Roach * @param Tree $tree 704db4b4a9SGreg Roach * @param array $parameters 714db4b4a9SGreg Roach * 724db4b4a9SGreg Roach * @return string 734db4b4a9SGreg Roach */ 7467992b6aSRichard Cissee public function listUrl(Tree $tree, array $parameters = []): string 7567992b6aSRichard Cissee { 7667992b6aSRichard Cissee return route('module', [ 7767992b6aSRichard Cissee 'module' => $this->name(), 7867992b6aSRichard Cissee 'action' => 'Page', 7967992b6aSRichard Cissee 'ged' => $tree->name(), 8067992b6aSRichard Cissee ] + $parameters); 8167992b6aSRichard Cissee } 8267992b6aSRichard Cissee 834db4b4a9SGreg Roach /** 846ccdf4f0SGreg Roach * @param ServerRequestInterface $request 854db4b4a9SGreg Roach * @param Tree $tree 864db4b4a9SGreg Roach * @param UserInterface $user 874db4b4a9SGreg Roach * 886ccdf4f0SGreg Roach * @return ResponseInterface 894db4b4a9SGreg Roach */ 906ccdf4f0SGreg Roach public function getPageAction(ServerRequestInterface $request, Tree $tree, UserInterface $user): ResponseInterface 9167992b6aSRichard Cissee { 92*96d794e7SGreg Roach Auth::checkComponentAccess($this, ModuleListInterface::class, $tree, $user); 9367992b6aSRichard Cissee 9467992b6aSRichard Cissee $listController = new BranchesController(app(ModuleService::class)); 9567992b6aSRichard Cissee return $listController->page($request); 9667992b6aSRichard Cissee } 9767992b6aSRichard Cissee 984db4b4a9SGreg Roach /** 996ccdf4f0SGreg Roach * @param ServerRequestInterface $request 1004db4b4a9SGreg Roach * @param Tree $tree 1014db4b4a9SGreg Roach * @param UserInterface $user 1024db4b4a9SGreg Roach * 1036ccdf4f0SGreg Roach * @return ResponseInterface 1044db4b4a9SGreg Roach */ 1056ccdf4f0SGreg Roach public function getListAction(ServerRequestInterface $request, Tree $tree, UserInterface $user): ResponseInterface 10667992b6aSRichard Cissee { 107*96d794e7SGreg Roach Auth::checkComponentAccess($this, ModuleListInterface::class, $tree, $user); 10867992b6aSRichard Cissee 10967992b6aSRichard Cissee $listController = new BranchesController(app(ModuleService::class)); 11067992b6aSRichard Cissee return $listController->list($request, $tree, $user); 11167992b6aSRichard Cissee } 11267992b6aSRichard Cissee 1134db4b4a9SGreg Roach /** 1144db4b4a9SGreg Roach * @return string[] 1154db4b4a9SGreg Roach */ 11667992b6aSRichard Cissee public function listUrlAttributes(): array 11767992b6aSRichard Cissee { 11867992b6aSRichard Cissee return []; 11967992b6aSRichard Cissee } 12067992b6aSRichard Cissee} 121