xref: /webtrees/app/Module/ModuleInterface.php (revision df27497a949ee94233b78915e33f253447a14e62)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Module;
21
22use Fisharebest\Webtrees\Tree;
23
24/**
25 * Interface ModuleInterface - Classes and libraries for module system
26 */
27interface ModuleInterface
28{
29    /**
30     * A unique internal name for this module (based on the installation folder).
31     *
32     * @param string $name
33     *
34     * @return void
35     */
36    public function setName(string $name): void;
37
38    /**
39     * A unique internal name for this module (based on the installation folder).
40     *
41     * @return string
42     */
43    public function name(): string;
44
45    /**
46     * Has the module been disabled in the control panel?
47     *
48     * @param bool $enabled
49     *
50     * @return self
51     */
52    public function setEnabled(bool $enabled): self;
53
54    /**
55     * Has the module been disabled in the control panel?
56     *
57     * @return bool
58     */
59    public function isEnabled(): bool;
60
61    /**
62     * Should this module be enabled when it is first installed?
63     *
64     * @return bool
65     */
66    public function isEnabledByDefault(): bool;
67
68    /**
69     * How should this module be identified in the control panel, etc.?
70     *
71     * @return string
72     */
73    public function title(): string;
74
75    /**
76     * A sentence describing what this module does.
77     *
78     * @return string
79     */
80    public function description(): string;
81
82    /**
83     * Get a the current access level for a module
84     *
85     * @param Tree   $tree
86     * @param string $interface
87     *
88     * @return int
89     */
90    public function accessLevel(Tree $tree, string $interface): int;
91
92    /**
93     * Get a module setting. Return a default if the setting is not set.
94     *
95     * @param string $setting_name
96     * @param string $default
97     *
98     * @return string
99     */
100    public function getPreference(string $setting_name, string $default = ''): string;
101
102    /**
103     * Set a module setting.
104     *
105     * Since module settings are NOT NULL, setting a value to NULL will cause
106     * it to be deleted.
107     *
108     * @param string $setting_name
109     * @param string $setting_value
110     *
111     * @return void
112     */
113    public function setPreference(string $setting_name, string $setting_value): void;
114
115    /**
116     * Where does this module store its resources
117     *
118     * @return string
119     */
120    public function resourcesFolder(): string;
121}
122