xref: /webtrees/app/Module/ModuleInterface.php (revision 9e6181127b6320ca605623bf22bb45fd1daffa71)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2019 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16declare(strict_types=1);
17
18namespace Fisharebest\Webtrees\Module;
19
20use Fisharebest\Webtrees\Tree;
21use Symfony\Component\HttpFoundation\Response;
22
23/**
24 * Interface ModuleInterface - Classes and libraries for module system
25 */
26interface ModuleInterface
27{
28    /**
29     * A unique internal name for this module (based on the installation folder).
30     *
31     * @param string $name
32     *
33     * @return void
34     */
35    public function setName(string $name): void;
36
37    /**
38     * A unique internal name for this module (based on the installation folder).
39     *
40     * @return string
41     */
42    public function name(): string;
43
44    /**
45     * Has the module been disabled in the control panel?
46     *
47     * @param bool $enabled
48     *
49     * @return self
50     */
51    public function setEnabled(bool $enabled): self;
52
53    /**
54     * Has the module been disabled in the control panel?
55     *
56     * @return bool
57     */
58    public function isEnabled(): bool;
59
60    /**
61     * Should this module be enabled when it is first installed?
62     *
63     * @return bool
64     */
65    public function isEnabledByDefault(): bool;
66
67    /**
68     * How should this module be identified in the control panel, etc.?
69     *
70     * @return string
71     */
72    public function title(): string;
73
74    /**
75     * A sentence describing what this module does.
76     *
77     * @return string
78     */
79    public function description(): string;
80
81    /**
82     * Get a the current access level for a module
83     *
84     * @param Tree   $tree
85     * @param string $interface
86     *
87     * @return int
88     */
89    public function accessLevel(Tree $tree, string $interface): int;
90
91    /**
92     * Get a module setting. Return a default if the setting is not set.
93     *
94     * @param string $setting_name
95     * @param string $default
96     *
97     * @return string
98     */
99    public function getPreference(string $setting_name, string $default = ''): string;
100
101    /**
102     * Set a module setting.
103     *
104     * Since module settings are NOT NULL, setting a value to NULL will cause
105     * it to be deleted.
106     *
107     * @param string $setting_name
108     * @param string $setting_value
109     *
110     * @return void
111     */
112    public function setPreference(string $setting_name, string $setting_value): void;
113
114    /**
115     * Where does this module store its resources
116     *
117     * @return string
118     */
119    public function resourcesFolder(): string;
120}
121