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