xref: /webtrees/app/Module/ModuleTabInterface.php (revision 5d7bcd6773d7da8e07d3d8d49e04e87086d93cd5)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2022 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Module;
21
22use Fisharebest\Webtrees\Individual;
23use Fisharebest\Webtrees\Tree;
24use Illuminate\Support\Collection;
25use Psr\Http\Message\ResponseInterface;
26use Psr\Http\Message\ServerRequestInterface;
27
28/**
29 * Interface ModuleTabInterface - Classes and libraries for module system
30 */
31interface ModuleTabInterface extends ModuleInterface
32{
33    /**
34     * The text that appears on the tab.
35     *
36     * @return string
37     */
38    public function tabTitle(): string;
39
40    /**
41     * Users change change the order of tabs using the control panel.
42     *
43     * @param int $tab_order
44     *
45     * @return void
46     */
47    public function setTabOrder(int $tab_order): void;
48
49    /**
50     * Users change change the order of tabs using the control panel.
51     *
52     * @return int
53     */
54    public function getTabOrder(): int;
55
56    /**
57     * The default position for this tab.  It can be changed in the control panel.
58     *
59     * @return int
60     */
61    public function defaultTabOrder(): int;
62
63    /**
64     * Generate the HTML content of this tab.
65     *
66     * @param Individual $individual
67     *
68     * @return string
69     */
70    public function getTabContent(Individual $individual): string;
71
72    /**
73     * Is this tab empty? If so, we don't always need to display it.
74     *
75     * @param Individual $individual
76     *
77     * @return bool
78     */
79    public function hasTabContent(Individual $individual): bool;
80
81    /**
82     * Can this tab load asynchronously?
83     *
84     * @return bool
85     */
86    public function canLoadAjax(): bool;
87
88    /**
89     * A greyed out tab has no actual content, but may perhaps have
90     * options to create content.
91     *
92     * @param Individual $individual
93     *
94     * @return bool
95     */
96    public function isGrayedOut(Individual $individual): bool;
97
98    /**
99     * This module handles the following facts - so don't show them on the "Facts and events" tab.
100     *
101     * @return Collection<int,string>
102     */
103    public function supportedFacts(): Collection;
104
105    /**
106     * Generate an AJAX response for a tab.
107     *
108     * @param ServerRequestInterface $request
109     *
110     * @return ResponseInterface
111     */
112    public function getTabAction(ServerRequestInterface $request): ResponseInterface;
113}
114