xref: /webtrees/app/Module/IndividualListModule.php (revision 67992b6a3e78399bd33189954a5f08bb23b02503)
1*67992b6aSRichard Cissee<?php
2*67992b6aSRichard Cissee/**
3*67992b6aSRichard Cissee * webtrees: online genealogy
4*67992b6aSRichard Cissee * Copyright (C) 2019 webtrees development team
5*67992b6aSRichard Cissee * This program is free software: you can redistribute it and/or modify
6*67992b6aSRichard Cissee * it under the terms of the GNU General Public License as published by
7*67992b6aSRichard Cissee * the Free Software Foundation, either version 3 of the License, or
8*67992b6aSRichard Cissee * (at your option) any later version.
9*67992b6aSRichard Cissee * This program is distributed in the hope that it will be useful,
10*67992b6aSRichard Cissee * but WITHOUT ANY WARRANTY; without even the implied warranty of
11*67992b6aSRichard Cissee * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12*67992b6aSRichard Cissee * GNU General Public License for more details.
13*67992b6aSRichard Cissee * You should have received a copy of the GNU General Public License
14*67992b6aSRichard Cissee * along with this program. If not, see <http://www.gnu.org/licenses/>.
15*67992b6aSRichard Cissee */
16*67992b6aSRichard Cisseedeclare(strict_types=1);
17*67992b6aSRichard Cissee
18*67992b6aSRichard Cisseenamespace Fisharebest\Webtrees\Module;
19*67992b6aSRichard Cissee
20*67992b6aSRichard Cisseeuse Fisharebest\Webtrees\Contracts\UserInterface;
21*67992b6aSRichard Cisseeuse Fisharebest\Webtrees\Http\Controllers\ListController;
22*67992b6aSRichard Cisseeuse Fisharebest\Webtrees\I18N;
23*67992b6aSRichard Cisseeuse Fisharebest\Webtrees\Services\IndividualListService;
24*67992b6aSRichard Cisseeuse Fisharebest\Webtrees\Services\LocalizationService;
25*67992b6aSRichard Cisseeuse Fisharebest\Webtrees\Tree;
26*67992b6aSRichard Cisseeuse Fisharebest\Webtrees\Auth;
27*67992b6aSRichard Cisseeuse Symfony\Component\HttpFoundation\Request;
28*67992b6aSRichard Cisseeuse Symfony\Component\HttpFoundation\Response;
29*67992b6aSRichard Cissee
30*67992b6aSRichard Cissee/**
31*67992b6aSRichard Cissee * Class IndividualListModule
32*67992b6aSRichard Cissee */
33*67992b6aSRichard Cisseeclass IndividualListModule extends AbstractModule implements ModuleListInterface
34*67992b6aSRichard Cissee{
35*67992b6aSRichard Cissee    use ModuleListTrait;
36*67992b6aSRichard Cissee
37*67992b6aSRichard Cissee    /**
38*67992b6aSRichard Cissee     * How should this module be labelled on tabs, menus, etc.?
39*67992b6aSRichard Cissee     *
40*67992b6aSRichard Cissee     * @return string
41*67992b6aSRichard Cissee     */
42*67992b6aSRichard Cissee    public function title(): string
43*67992b6aSRichard Cissee    {
44*67992b6aSRichard Cissee        /* I18N: Name of a module/list */
45*67992b6aSRichard Cissee        return I18N::translate('Individuals');
46*67992b6aSRichard Cissee    }
47*67992b6aSRichard Cissee
48*67992b6aSRichard Cissee    /**
49*67992b6aSRichard Cissee     * A sentence describing what this module does.
50*67992b6aSRichard Cissee     *
51*67992b6aSRichard Cissee     * @return string
52*67992b6aSRichard Cissee     */
53*67992b6aSRichard Cissee    public function description(): string
54*67992b6aSRichard Cissee    {
55*67992b6aSRichard Cissee        /* I18N: Description of the “IndividualListModule” module */
56*67992b6aSRichard Cissee        return I18N::translate('A list of individuals.');
57*67992b6aSRichard Cissee    }
58*67992b6aSRichard Cissee
59*67992b6aSRichard Cissee    /**
60*67992b6aSRichard Cissee     * CSS class for the URL.
61*67992b6aSRichard Cissee     *
62*67992b6aSRichard Cissee     * @return string
63*67992b6aSRichard Cissee     */
64*67992b6aSRichard Cissee    public function listMenuClass(): string
65*67992b6aSRichard Cissee    {
66*67992b6aSRichard Cissee        return 'menu-list-indi';
67*67992b6aSRichard Cissee    }
68*67992b6aSRichard Cissee
69*67992b6aSRichard Cissee    public function getListAction(Request $request, Tree $tree, UserInterface $user): Response
70*67992b6aSRichard Cissee    {
71*67992b6aSRichard Cissee        Auth::checkComponentAccess($this, 'list', $tree, $user);
72*67992b6aSRichard Cissee
73*67992b6aSRichard Cissee        $listController = new ListController(app(IndividualListService::class), app(LocalizationService::class));
74*67992b6aSRichard Cissee        return $listController->individualList($this, $request, $tree, $user);
75*67992b6aSRichard Cissee    }
76*67992b6aSRichard Cissee
77*67992b6aSRichard Cissee    public function listUrlAttributes(): array
78*67992b6aSRichard Cissee    {
79*67992b6aSRichard Cissee        return [];
80*67992b6aSRichard Cissee    }
81*67992b6aSRichard Cissee}
82