1027c6af4SGreg Roach<?php 23976b470SGreg Roach 3027c6af4SGreg Roach/** 4027c6af4SGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 6027c6af4SGreg Roach * This program is free software: you can redistribute it and/or modify 7027c6af4SGreg Roach * it under the terms of the GNU General Public License as published by 8027c6af4SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9027c6af4SGreg Roach * (at your option) any later version. 10027c6af4SGreg Roach * This program is distributed in the hope that it will be useful, 11027c6af4SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12027c6af4SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13027c6af4SGreg Roach * GNU General Public License for more details. 14027c6af4SGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 16027c6af4SGreg Roach */ 17fcfa147eSGreg Roach 18027c6af4SGreg Roachdeclare(strict_types=1); 19027c6af4SGreg Roach 20027c6af4SGreg Roachnamespace Fisharebest\Webtrees\Module; 21027c6af4SGreg Roach 2249a243cbSGreg Roachuse Fisharebest\Webtrees\Tree; 2349a243cbSGreg Roach 24027c6af4SGreg Roach/** 25027c6af4SGreg Roach * Interface ModuleInterface - Classes and libraries for module system 26027c6af4SGreg Roach */ 27027c6af4SGreg Roachinterface ModuleInterface 28027c6af4SGreg Roach{ 29027c6af4SGreg Roach /** 309e18e23bSGreg Roach * Early initialisation. Called before most of the middleware. 319e18e23bSGreg Roach */ 329e18e23bSGreg Roach public function boot(): void; 339e18e23bSGreg Roach 349e18e23bSGreg Roach /** 3549a243cbSGreg Roach * A unique internal name for this module (based on the installation folder). 36027c6af4SGreg Roach * 3749a243cbSGreg Roach * @param string $name 3849a243cbSGreg Roach * 3937eb8894SGreg Roach * @return void 40027c6af4SGreg Roach */ 4137eb8894SGreg Roach public function setName(string $name): void; 4249a243cbSGreg Roach 4349a243cbSGreg Roach /** 4449a243cbSGreg Roach * A unique internal name for this module (based on the installation folder). 4549a243cbSGreg Roach * 4649a243cbSGreg Roach * @return string 4749a243cbSGreg Roach */ 4826684e68SGreg Roach public function name(): string; 4949a243cbSGreg Roach 5049a243cbSGreg Roach /** 5149a243cbSGreg Roach * Has the module been disabled in the control panel? 5249a243cbSGreg Roach * 5349a243cbSGreg Roach * @param bool $enabled 5449a243cbSGreg Roach * 5549a243cbSGreg Roach * @return self 5649a243cbSGreg Roach */ 5749a243cbSGreg Roach public function setEnabled(bool $enabled): self; 5849a243cbSGreg Roach 5949a243cbSGreg Roach /** 6049a243cbSGreg Roach * Has the module been disabled in the control panel? 6149a243cbSGreg Roach * 6249a243cbSGreg Roach * @return bool 6349a243cbSGreg Roach */ 6449a243cbSGreg Roach public function isEnabled(): bool; 65027c6af4SGreg Roach 66027c6af4SGreg Roach /** 67888ddf4fSGreg Roach * Should this module be enabled when it is first installed? 68888ddf4fSGreg Roach * 69888ddf4fSGreg Roach * @return bool 70888ddf4fSGreg Roach */ 71888ddf4fSGreg Roach public function isEnabledByDefault(): bool; 72888ddf4fSGreg Roach 73888ddf4fSGreg Roach /** 740cfd6963SGreg Roach * How should this module be identified in the control panel, etc.? 75027c6af4SGreg Roach * 76027c6af4SGreg Roach * @return string 77027c6af4SGreg Roach */ 7849a243cbSGreg Roach public function title(): string; 79027c6af4SGreg Roach 8049a243cbSGreg Roach public function description(): string; 81027c6af4SGreg Roach 82027c6af4SGreg Roach /** 83*ac19d600SGreg Roach * Get the current access level for a module 84*ac19d600SGreg Roach * 85*ac19d600SGreg Roach * @template T of ModuleInterface 86027c6af4SGreg Roach * 8749a243cbSGreg Roach * @param Tree $tree 88*ac19d600SGreg Roach * @param class-string<T> $interface 89027c6af4SGreg Roach * 9049a243cbSGreg Roach * @return int 91027c6af4SGreg Roach */ 9287cca37cSGreg Roach public function accessLevel(Tree $tree, string $interface): int; 9337eb8894SGreg Roach 9437eb8894SGreg Roach /** 9537eb8894SGreg Roach * Get a module setting. Return a default if the setting is not set. 9637eb8894SGreg Roach * 9737eb8894SGreg Roach * @param string $setting_name 9837eb8894SGreg Roach * @param string $default 9937eb8894SGreg Roach * 10037eb8894SGreg Roach * @return string 10137eb8894SGreg Roach */ 10237eb8894SGreg Roach public function getPreference(string $setting_name, string $default = ''): string; 10337eb8894SGreg Roach 10437eb8894SGreg Roach /** 10537eb8894SGreg Roach * Set a module setting. 10637eb8894SGreg Roach * 10737eb8894SGreg Roach * Since module settings are NOT NULL, setting a value to NULL will cause 10837eb8894SGreg Roach * it to be deleted. 10937eb8894SGreg Roach * 11037eb8894SGreg Roach * @param string $setting_name 11137eb8894SGreg Roach * @param string $setting_value 11237eb8894SGreg Roach * 113ea02ddf4SGreg Roach * @return void 11437eb8894SGreg Roach */ 11537eb8894SGreg Roach public function setPreference(string $setting_name, string $setting_value): void; 11602086832SGreg Roach 11702086832SGreg Roach /** 11802086832SGreg Roach * Where does this module store its resources 11902086832SGreg Roach * 12002086832SGreg Roach * @return string 12102086832SGreg Roach */ 12202086832SGreg Roach public function resourcesFolder(): string; 123027c6af4SGreg Roach} 124