14ca7e03cSGreg Roach<?php 23976b470SGreg Roach 34ca7e03cSGreg Roach/** 44ca7e03cSGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 64ca7e03cSGreg Roach * This program is free software: you can redistribute it and/or modify 74ca7e03cSGreg Roach * it under the terms of the GNU General Public License as published by 84ca7e03cSGreg Roach * the Free Software Foundation, either version 3 of the License, or 94ca7e03cSGreg Roach * (at your option) any later version. 104ca7e03cSGreg Roach * This program is distributed in the hope that it will be useful, 114ca7e03cSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 124ca7e03cSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 134ca7e03cSGreg Roach * GNU General Public License for more details. 144ca7e03cSGreg 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/>. 164ca7e03cSGreg Roach */ 17fcfa147eSGreg Roach 184ca7e03cSGreg Roachdeclare(strict_types=1); 194ca7e03cSGreg Roach 204ca7e03cSGreg Roachnamespace Fisharebest\Webtrees\Services; 214ca7e03cSGreg Roach 224ca7e03cSGreg Roachuse Closure; 234ca7e03cSGreg Roachuse Fisharebest\Webtrees\Auth; 24e5a6b4d4SGreg Roachuse Fisharebest\Webtrees\Contracts\UserInterface; 256f4ec3caSGreg Roachuse Fisharebest\Webtrees\DB; 265bc7939cSBenuse Fisharebest\Webtrees\FlashMessages; 279e18e23bSGreg Roachuse Fisharebest\Webtrees\I18N; 284ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\AhnentafelReportModule; 294ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\AlbumModule; 304ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\AncestorsChartModule; 31fa24d895SGreg Roachuse Fisharebest\Webtrees\Module\AustrianHistoricEvents; 323b387b05SGreg Roachuse Fisharebest\Webtrees\Module\AustrianPresidents; 33f0c88a96SGreg Roachuse Fisharebest\Webtrees\Module\BingMaps; 344ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\BingWebmasterToolsModule; 354ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\BirthDeathMarriageReportModule; 364ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\BirthReportModule; 3767992b6aSRichard Cisseeuse Fisharebest\Webtrees\Module\BranchesListModule; 3809fbf3e5SGreg Roachuse Fisharebest\Webtrees\Module\BritishMonarchs; 3909fbf3e5SGreg Roachuse Fisharebest\Webtrees\Module\BritishPrimeMinisters; 4009fbf3e5SGreg Roachuse Fisharebest\Webtrees\Module\BritishSocialHistory; 414ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\CalendarMenuModule; 424ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\CemeteryReportModule; 434ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\CensusAssistantModule; 444ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ChangeReportModule; 454ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ChartsBlockModule; 464ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ChartsMenuModule; 471898855eSGreg Roachuse Fisharebest\Webtrees\Module\CheckForNewVersion; 484ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\CkeditorModule; 494ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ClippingsCartModule; 504ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\CloudsTheme; 514ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ColorsTheme; 524ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\CompactTreeChartModule; 534ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ContactsFooterModule; 548d6560c4SGreg Roachuse Fisharebest\Webtrees\Module\CustomCssJsModule; 55c2ee636cSGreg Roachuse Fisharebest\Webtrees\Module\CzechMonarchsAndPresidents; 564ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\DeathReportModule; 574ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\DescendancyChartModule; 584ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\DescendancyModule; 594ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\DescendancyReportModule; 60c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\DutchMonarchs; 61c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\DutchPrimeMinisters; 62c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\EsriMaps; 634ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\FabTheme; 644ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\FactSourcesReportModule; 654ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\FamilyBookChartModule; 664ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\FamilyGroupReportModule; 6767992b6aSRichard Cisseeuse Fisharebest\Webtrees\Module\FamilyListModule; 684ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\FamilyNavigatorModule; 694ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\FamilyTreeFavoritesModule; 704ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\FamilyTreeNewsModule; 714ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\FamilyTreeStatisticsModule; 724ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\FanChartModule; 73ce42304aSGreg Roachuse Fisharebest\Webtrees\Module\FixCemeteryTag; 74ce42304aSGreg Roachuse Fisharebest\Webtrees\Module\FixDuplicateLinks; 75ce42304aSGreg Roachuse Fisharebest\Webtrees\Module\FixMissingDeaths; 76ce42304aSGreg Roachuse Fisharebest\Webtrees\Module\FixNameSlashesAndSpaces; 77a50fee42SGreg Roachuse Fisharebest\Webtrees\Module\FixNameTags; 78ce42304aSGreg Roachuse Fisharebest\Webtrees\Module\FixPlaceNames; 79ce42304aSGreg Roachuse Fisharebest\Webtrees\Module\FixPrimaryTag; 80ce42304aSGreg Roachuse Fisharebest\Webtrees\Module\FixSearchAndReplace; 81e93aa0bdSGreg Roachuse Fisharebest\Webtrees\Module\FixWtObjeSortTag; 82a50fee42SGreg Roachuse Fisharebest\Webtrees\Module\FrenchHistory; 834ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\FrequentlyAskedQuestionsModule; 84c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\GeonamesAutocomplete; 854ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\GoogleAnalyticsModule; 86f0c88a96SGreg Roachuse Fisharebest\Webtrees\Module\GoogleMaps; 874ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\GoogleWebmasterToolsModule; 88c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\HereMaps; 894ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\HitCountFooterModule; 904ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\HourglassChartModule; 914ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\HtmlBlockModule; 924ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\IndividualFactsTabModule; 934ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\IndividualFamiliesReportModule; 9467992b6aSRichard Cisseeuse Fisharebest\Webtrees\Module\IndividualListModule; 9509fbf3e5SGreg Roachuse Fisharebest\Webtrees\Module\IndividualMetadataModule; 964ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\IndividualReportModule; 974ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\InteractiveTreeModule; 9802086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageAfrikaans; 9902086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageAlbanian; 10002086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageArabic; 101bfc3bea8SGreg Roachuse Fisharebest\Webtrees\Module\LanguageBasque; 10202086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageBosnian; 10302086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageBulgarian; 10402086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageCatalan; 10502086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageChineseSimplified; 10602086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageChineseTraditional; 10702086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageCroatian; 10802086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageCzech; 10902086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageDanish; 11002086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageDivehi; 11102086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageDutch; 11202086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageEnglishAustralia; 11302086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageEnglishGreatBritain; 11402086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageEnglishUnitedStates; 11502086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageEstonian; 11602086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageFaroese; 11702086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageFarsi; 11802086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageFinnish; 11902086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageFrench; 12002086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageFrenchCanada; 12102086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageGalician; 12202086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageGeorgian; 12302086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageGerman; 12402086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageGreek; 12502086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageHebrew; 1260f180719SGreg Roachuse Fisharebest\Webtrees\Module\LanguageHindi; 12702086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageHungarian; 12802086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageIcelandic; 12902086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageIndonesian; 13002086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageItalian; 13102086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageJapanese; 13202086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageJavanese; 13302086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageKazhak; 13402086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageKorean; 135015d9fbcSGreg Roachuse Fisharebest\Webtrees\Module\LanguageKurdish; 13602086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageLatvian; 13702086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageLingala; 13802086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageLithuanian; 13902086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageMalay; 14002086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageMaori; 14102086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageMarathi; 14202086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageNepalese; 14302086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageNorwegianBokmal; 14402086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageNorwegianNynorsk; 14502086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageOccitan; 14602086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguagePolish; 14702086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguagePortuguese; 14802086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguagePortugueseBrazil; 14902086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageRomanian; 15002086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageRussian; 15102086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageSerbian; 15202086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageSerbianLatin; 15302086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageSlovakian; 15402086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageSlovenian; 15502086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageSpanish; 15602086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageSundanese; 15702086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageSwahili; 15802086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageSwedish; 159d7e19759SGreg Roachuse Fisharebest\Webtrees\Module\LanguageTagalog; 16002086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageTamil; 16102086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageTatar; 16202086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageThai; 16302086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageTurkish; 16402086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageUkranian; 1653ca31ad9SGreg Roachuse Fisharebest\Webtrees\Module\LanguageUrdu; 16681b514b4SGreg Roachuse Fisharebest\Webtrees\Module\LanguageUzbek; 16702086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageVietnamese; 1689fb58c9eSGreg Roachuse Fisharebest\Webtrees\Module\LanguageWelsh; 16902086832SGreg Roachuse Fisharebest\Webtrees\Module\LanguageYiddish; 1704ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\LifespansChartModule; 1714ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ListsMenuModule; 172c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\LocationListModule; 1734ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\LoggedInUsersModule; 1744ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\LoginBlockModule; 175c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\LowCountriesRulers; 176c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\MapBox; 177c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\MapGeoLocationGeonames; 178c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\MapGeoLocationNominatim; 179c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\MapGeoLocationOpenRouteService; 180f0c88a96SGreg Roachuse Fisharebest\Webtrees\Module\MapLinkBing; 181f0c88a96SGreg Roachuse Fisharebest\Webtrees\Module\MapLinkGoogle; 182f0c88a96SGreg Roachuse Fisharebest\Webtrees\Module\MapLinkOpenStreetMap; 1834ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\MarriageReportModule; 1844ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\MatomoAnalyticsModule; 18567992b6aSRichard Cisseeuse Fisharebest\Webtrees\Module\MediaListModule; 1864ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\MediaTabModule; 1874ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\MinimalTheme; 1884ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\MissingFactsReportModule; 189bf57b580SGreg Roachuse Fisharebest\Webtrees\Module\ModuleAnalyticsInterface; 1904ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleBlockInterface; 1914ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleChartInterface; 1924ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleCustomInterface; 193ce42304aSGreg Roachuse Fisharebest\Webtrees\Module\ModuleDataFixInterface; 1944ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleFooterInterface; 195bf57b580SGreg Roachuse Fisharebest\Webtrees\Module\ModuleHistoricEventsInterface; 1964ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleInterface; 197bf57b580SGreg Roachuse Fisharebest\Webtrees\Module\ModuleLanguageInterface; 19867992b6aSRichard Cisseeuse Fisharebest\Webtrees\Module\ModuleListInterface; 199f0c88a96SGreg Roachuse Fisharebest\Webtrees\Module\ModuleMapAutocompleteInterface; 200c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\ModuleMapGeoLocationInterface; 201f0c88a96SGreg Roachuse Fisharebest\Webtrees\Module\ModuleMapLinkInterface; 202c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\ModuleMapProviderInterface; 2034ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleMenuInterface; 2044ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleReportInterface; 205c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\ModuleShareInterface; 2064ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleSidebarInterface; 2074ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleTabInterface; 208bf57b580SGreg Roachuse Fisharebest\Webtrees\Module\ModuleThemeInterface; 209*14974d95SRAMINCNZuse Fisharebest\Webtrees\Module\NewZealandPrimeMinisters; 21067992b6aSRichard Cisseeuse Fisharebest\Webtrees\Module\NoteListModule; 2114ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\NotesTabModule; 2124ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\OccupationReportModule; 2134ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\OnThisDayModule; 214f0c88a96SGreg Roachuse Fisharebest\Webtrees\Module\OpenRouteServiceAutocomplete; 215f0c88a96SGreg Roachuse Fisharebest\Webtrees\Module\OpenStreetMap; 2164ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\PedigreeChartModule; 2174ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\PedigreeMapModule; 2184ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\PedigreeReportModule; 21967992b6aSRichard Cisseeuse Fisharebest\Webtrees\Module\PlaceHierarchyListModule; 2204ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\PlacesModule; 2214ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\PoweredByWebtreesModule; 222b3a775f6SGreg Roachuse Fisharebest\Webtrees\Module\PrivacyPolicy; 2234ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\RecentChangesModule; 224c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\RedirectLegacyUrlsModule; 2254ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\RelatedIndividualsReportModule; 2264ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\RelationshipsChartModule; 2274ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\RelativesTabModule; 2284ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ReportsMenuModule; 22967992b6aSRichard Cisseeuse Fisharebest\Webtrees\Module\RepositoryListModule; 2304ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ResearchTaskModule; 2314ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ReviewChangesModule; 2324ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\SearchMenuModule; 233c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\ShareAnniversaryModule; 234c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Module\ShareUrlModule; 2354ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\SiteMapModule; 2364ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\SlideShowModule; 23767992b6aSRichard Cisseeuse Fisharebest\Webtrees\Module\SourceListModule; 2384ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\SourcesTabModule; 2394ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\StatcounterModule; 2404ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\StatisticsChartModule; 2414ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\StoriesModule; 242e72c24d6SGreg Roachuse Fisharebest\Webtrees\Module\SubmitterListModule; 2434ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\ThemeSelectModule; 2444ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\TimelineChartModule; 2454ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\TopGivenNamesModule; 2464ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\TopPageViewsModule; 2474ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\TopSurnamesModule; 2484ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\TreesMenuModule; 2494ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\UpcomingAnniversariesModule; 2504ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\UserFavoritesModule; 2514ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\UserJournalModule; 2524ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\UserMessagesModule; 2534ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\UserWelcomeModule; 25409fbf3e5SGreg Roachuse Fisharebest\Webtrees\Module\USPresidents; 2554ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\WebtreesTheme; 2564ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\WelcomeBlockModule; 2574ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\XeneaTheme; 2584ca7e03cSGreg Roachuse Fisharebest\Webtrees\Module\YahrzeitModule; 259c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Registry; 2604ca7e03cSGreg Roachuse Fisharebest\Webtrees\Tree; 2614ca7e03cSGreg Roachuse Fisharebest\Webtrees\Webtrees; 2624ca7e03cSGreg Roachuse Illuminate\Support\Collection; 263ac19d600SGreg Roachuse Psr\Http\Server\MiddlewareInterface; 2644ca7e03cSGreg Roachuse Throwable; 2654ca7e03cSGreg Roach 266a9866bf2SGreg Roachuse function basename; 267a9866bf2SGreg Roachuse function dirname; 268a9866bf2SGreg Roachuse function glob; 269f70bcff5SGreg Roachuse function is_object; 270dec352c1SGreg Roachuse function str_contains; 271dec352c1SGreg Roachuse function strlen; 27271378461SGreg Roach 273a9866bf2SGreg Roachuse const GLOB_NOSORT; 274a9866bf2SGreg Roach 2754ca7e03cSGreg Roach/** 2764ca7e03cSGreg Roach * Functions for managing and maintaining modules. 2774ca7e03cSGreg Roach */ 2784ca7e03cSGreg Roachclass ModuleService 2794ca7e03cSGreg Roach{ 280362b8464SGreg Roach // Components are pieces of user-facing functionality, are managed together in the control panel. 2814ca7e03cSGreg Roach private const COMPONENTS = [ 28287cca37cSGreg Roach ModuleAnalyticsInterface::class, 28387cca37cSGreg Roach ModuleBlockInterface::class, 28487cca37cSGreg Roach ModuleChartInterface::class, 285ce42304aSGreg Roach ModuleDataFixInterface::class, 28687cca37cSGreg Roach ModuleFooterInterface::class, 28787cca37cSGreg Roach ModuleHistoricEventsInterface::class, 28887cca37cSGreg Roach ModuleLanguageInterface::class, 28987cca37cSGreg Roach ModuleListInterface::class, 290c9c6f2ecSGreg Roach ModuleMapAutocompleteInterface::class, 291e3544cb2SGreg Roach ModuleMapLinkInterface::class, 292c9c6f2ecSGreg Roach ModuleMapProviderInterface::class, 293c9c6f2ecSGreg Roach ModuleMapGeoLocationInterface::class, 29487cca37cSGreg Roach ModuleMenuInterface::class, 29587cca37cSGreg Roach ModuleReportInterface::class, 296853f2b8aSGreg Roach ModuleShareInterface::class, 29787cca37cSGreg Roach ModuleSidebarInterface::class, 29887cca37cSGreg Roach ModuleTabInterface::class, 29987cca37cSGreg Roach ModuleThemeInterface::class, 3004ca7e03cSGreg Roach ]; 3014ca7e03cSGreg Roach 302745968f0SGreg Roach // Components that have access levels. 303745968f0SGreg Roach private const COMPONENTS_WITH_ACCESS = [ 304745968f0SGreg Roach ModuleBlockInterface::class, 305745968f0SGreg Roach ModuleChartInterface::class, 306745968f0SGreg Roach ModuleListInterface::class, 307745968f0SGreg Roach ModuleMenuInterface::class, 308745968f0SGreg Roach ModuleReportInterface::class, 309745968f0SGreg Roach ModuleSidebarInterface::class, 310745968f0SGreg Roach ModuleTabInterface::class, 311745968f0SGreg Roach ]; 312745968f0SGreg Roach 313745968f0SGreg Roach // Components that are displayed in a particular order 314745968f0SGreg Roach private const COMPONENTS_WITH_SORT = [ 315745968f0SGreg Roach ModuleFooterInterface::class, 316745968f0SGreg Roach ModuleMenuInterface::class, 317745968f0SGreg Roach ModuleSidebarInterface::class, 318745968f0SGreg Roach ModuleTabInterface::class, 319745968f0SGreg Roach ]; 320745968f0SGreg Roach 3214ca7e03cSGreg Roach // Array keys are module names, and should match module names from earlier versions of webtrees. 3224ca7e03cSGreg Roach private const CORE_MODULES = [ 3234ca7e03cSGreg Roach 'GEDFact_assistant' => CensusAssistantModule::class, 3244ca7e03cSGreg Roach 'ahnentafel_report' => AhnentafelReportModule::class, 3254ca7e03cSGreg Roach 'ancestors_chart' => AncestorsChartModule::class, 326fa24d895SGreg Roach 'austrian-history' => AustrianHistoricEvents::class, 3273b387b05SGreg Roach 'austrian-presidents' => AustrianPresidents::class, 3284ca7e03cSGreg Roach 'bdm_report' => BirthDeathMarriageReportModule::class, 329c9c6f2ecSGreg Roach 'bing-maps' => BingMaps::class, 3304ca7e03cSGreg Roach 'bing-webmaster-tools' => BingWebmasterToolsModule::class, 3314ca7e03cSGreg Roach 'birth_report' => BirthReportModule::class, 33267992b6aSRichard Cissee 'branches_list' => BranchesListModule::class, 33309fbf3e5SGreg Roach 'british-monarchs' => BritishMonarchs::class, 33409fbf3e5SGreg Roach 'british-prime-ministers' => BritishPrimeMinisters::class, 33509fbf3e5SGreg Roach 'british-social-history' => BritishSocialHistory::class, 3364ca7e03cSGreg Roach 'calendar-menu' => CalendarMenuModule::class, 3374ca7e03cSGreg Roach 'cemetery_report' => CemeteryReportModule::class, 3384ca7e03cSGreg Roach 'change_report' => ChangeReportModule::class, 3394ca7e03cSGreg Roach 'charts' => ChartsBlockModule::class, 3404ca7e03cSGreg Roach 'charts-menu' => ChartsMenuModule::class, 3411898855eSGreg Roach 'check-for-new-version' => CheckForNewVersion::class, 3424ca7e03cSGreg Roach 'ckeditor' => CkeditorModule::class, 3434ca7e03cSGreg Roach 'clippings' => ClippingsCartModule::class, 3444ca7e03cSGreg Roach 'clouds' => CloudsTheme::class, 3454ca7e03cSGreg Roach 'colors' => ColorsTheme::class, 3464ca7e03cSGreg Roach 'compact-chart' => CompactTreeChartModule::class, 3474ca7e03cSGreg Roach 'contact-links' => ContactsFooterModule::class, 348c2ee636cSGreg Roach 'czech-leaders' => CzechMonarchsAndPresidents::class, 3498d6560c4SGreg Roach 'custom-css-js' => CustomCssJsModule::class, 3504ca7e03cSGreg Roach 'death_report' => DeathReportModule::class, 3514ca7e03cSGreg Roach 'descendancy' => DescendancyModule::class, 3524ca7e03cSGreg Roach 'descendancy_chart' => DescendancyChartModule::class, 3534ca7e03cSGreg Roach 'descendancy_report' => DescendancyReportModule::class, 35482be4a69SGreg Roach 'dutch_monarchs' => DutchMonarchs::class, 35582be4a69SGreg Roach 'dutch_prime_ministers' => DutchPrimeMinisters::class, 356c9c6f2ecSGreg Roach 'esri-maps' => EsriMaps::class, 3578eaf8709SGreg Roach 'extra_info' => IndividualMetadataModule::class, 3584ca7e03cSGreg Roach 'fab' => FabTheme::class, 3594ca7e03cSGreg Roach 'fact_sources' => FactSourcesReportModule::class, 3604ca7e03cSGreg Roach 'family_book_chart' => FamilyBookChartModule::class, 3614ca7e03cSGreg Roach 'family_group_report' => FamilyGroupReportModule::class, 36267992b6aSRichard Cissee 'family_list' => FamilyListModule::class, 3634ca7e03cSGreg Roach 'family_nav' => FamilyNavigatorModule::class, 3644ca7e03cSGreg Roach 'fan_chart' => FanChartModule::class, 3654ca7e03cSGreg Roach 'faq' => FrequentlyAskedQuestionsModule::class, 366f466a2a5SGreg Roach 'french-history' => FrenchHistory::class, 367ce42304aSGreg Roach 'fix-add-death' => FixMissingDeaths::class, 36876937c18SGreg Roach 'fix-ceme-tag' => FixCemeteryTag::class, 369ce42304aSGreg Roach 'fix-duplicate-links' => FixDuplicateLinks::class, 370ce42304aSGreg Roach 'fix-name-slashes-spaces' => FixNameSlashesAndSpaces::class, 371042e1af7SGreg Roach 'fix-name-tags' => FixNameTags::class, 37229a51599SGreg Roach 'fix-place-names' => FixPlaceNames::class, 373ce42304aSGreg Roach 'fix-prim-tag' => FixPrimaryTag::class, 374ce42304aSGreg Roach 'fix-search-and-replace' => FixSearchAndReplace::class, 375e93aa0bdSGreg Roach 'fix-wt-obje-sort' => FixWtObjeSortTag::class, 3764ca7e03cSGreg Roach 'gedcom_block' => WelcomeBlockModule::class, 3774ca7e03cSGreg Roach 'gedcom_favorites' => FamilyTreeFavoritesModule::class, 3784ca7e03cSGreg Roach 'gedcom_news' => FamilyTreeNewsModule::class, 3794ca7e03cSGreg Roach 'gedcom_stats' => FamilyTreeStatisticsModule::class, 380c9c6f2ecSGreg Roach 'geonames' => GeonamesAutocomplete::class, 3814ca7e03cSGreg Roach 'google-analytics' => GoogleAnalyticsModule::class, 382c9c6f2ecSGreg Roach 'google-maps' => GoogleMaps::class, 3834ca7e03cSGreg Roach 'google-webmaster-tools' => GoogleWebmasterToolsModule::class, 384c9c6f2ecSGreg Roach 'here-maps' => HereMaps::class, 3854ca7e03cSGreg Roach 'hit-counter' => HitCountFooterModule::class, 3864ca7e03cSGreg Roach 'hourglass_chart' => HourglassChartModule::class, 3874ca7e03cSGreg Roach 'html' => HtmlBlockModule::class, 3884ca7e03cSGreg Roach 'individual_ext_report' => IndividualFamiliesReportModule::class, 38967992b6aSRichard Cissee 'individual_list' => IndividualListModule::class, 3904ca7e03cSGreg Roach 'individual_report' => IndividualReportModule::class, 39102086832SGreg Roach 'language-af' => LanguageAfrikaans::class, 39202086832SGreg Roach 'language-ar' => LanguageArabic::class, 393899f7f5fSGreg Roach 'language-bg' => LanguageBulgarian::class, 39402086832SGreg Roach 'language-bs' => LanguageBosnian::class, 39502086832SGreg Roach 'language-ca' => LanguageCatalan::class, 39602086832SGreg Roach 'language-cs' => LanguageCzech::class, 3979fb58c9eSGreg Roach 'language-cy' => LanguageWelsh::class, 39802086832SGreg Roach 'language-da' => LanguageDanish::class, 39902086832SGreg Roach 'language-de' => LanguageGerman::class, 40002086832SGreg Roach 'language-dv' => LanguageDivehi::class, 40102086832SGreg Roach 'language-el' => LanguageGreek::class, 40202086832SGreg Roach 'language-en-AU' => LanguageEnglishAustralia::class, 40302086832SGreg Roach 'language-en-GB' => LanguageEnglishGreatBritain::class, 40402086832SGreg Roach 'language-en-US' => LanguageEnglishUnitedStates::class, 40502086832SGreg Roach 'language-es' => LanguageSpanish::class, 40602086832SGreg Roach 'language-et' => LanguageEstonian::class, 407bfc3bea8SGreg Roach 'language-eu' => LanguageBasque::class, 40802086832SGreg Roach 'language-fa' => LanguageFarsi::class, 40902086832SGreg Roach 'language-fi' => LanguageFinnish::class, 41002086832SGreg Roach 'language-fo' => LanguageFaroese::class, 41102086832SGreg Roach 'language-fr' => LanguageFrench::class, 41202086832SGreg Roach 'language-fr-CA' => LanguageFrenchCanada::class, 41302086832SGreg Roach 'language-gl' => LanguageGalician::class, 41402086832SGreg Roach 'language-he' => LanguageHebrew::class, 4150f180719SGreg Roach 'language-hi' => LanguageHindi::class, 41602086832SGreg Roach 'language-hr' => LanguageCroatian::class, 41702086832SGreg Roach 'language-hu' => LanguageHungarian::class, 41802086832SGreg Roach 'language-id' => LanguageIndonesian::class, 41902086832SGreg Roach 'language-is' => LanguageIcelandic::class, 42002086832SGreg Roach 'language-it' => LanguageItalian::class, 42102086832SGreg Roach 'language-ja' => LanguageJapanese::class, 42202086832SGreg Roach 'language-jv' => LanguageJavanese::class, 42302086832SGreg Roach 'language-ka' => LanguageGeorgian::class, 42402086832SGreg Roach 'language-kk' => LanguageKazhak::class, 42502086832SGreg Roach 'language-ko' => LanguageKorean::class, 426015d9fbcSGreg Roach 'language-ku' => LanguageKurdish::class, 42702086832SGreg Roach 'language-ln' => LanguageLingala::class, 42802086832SGreg Roach 'language-lt' => LanguageLithuanian::class, 42902086832SGreg Roach 'language-lv' => LanguageLatvian::class, 43002086832SGreg Roach 'language-mi' => LanguageMaori::class, 43102086832SGreg Roach 'language-mr' => LanguageMarathi::class, 43202086832SGreg Roach 'language-ms' => LanguageMalay::class, 43302086832SGreg Roach 'language-nb' => LanguageNorwegianBokmal::class, 43402086832SGreg Roach 'language-ne' => LanguageNepalese::class, 43502086832SGreg Roach 'language-nl' => LanguageDutch::class, 43602086832SGreg Roach 'language-nn' => LanguageNorwegianNynorsk::class, 43702086832SGreg Roach 'language-oc' => LanguageOccitan::class, 43802086832SGreg Roach 'language-pl' => LanguagePolish::class, 43902086832SGreg Roach 'language-pt' => LanguagePortuguese::class, 44002086832SGreg Roach 'language-pt-BR' => LanguagePortugueseBrazil::class, 44102086832SGreg Roach 'language-ro' => LanguageRomanian::class, 44202086832SGreg Roach 'language-ru' => LanguageRussian::class, 44302086832SGreg Roach 'language-sk' => LanguageSlovakian::class, 44402086832SGreg Roach 'language-sl' => LanguageSlovenian::class, 44502086832SGreg Roach 'language-sq' => LanguageAlbanian::class, 44602086832SGreg Roach 'language-sr' => LanguageSerbian::class, 44702086832SGreg Roach 'language-sr-Latn' => LanguageSerbianLatin::class, 44802086832SGreg Roach 'language-su' => LanguageSundanese::class, 44902086832SGreg Roach 'language-sv' => LanguageSwedish::class, 45002086832SGreg Roach 'language-sw' => LanguageSwahili::class, 45102086832SGreg Roach 'language-ta' => LanguageTamil::class, 45202086832SGreg Roach 'language-th' => LanguageThai::class, 453d7e19759SGreg Roach 'language-tl' => LanguageTagalog::class, 45402086832SGreg Roach 'language-tr' => LanguageTurkish::class, 45502086832SGreg Roach 'language-tt' => LanguageTatar::class, 45602086832SGreg Roach 'language-uk' => LanguageUkranian::class, 4573ca31ad9SGreg Roach 'language-ur' => LanguageUrdu::class, 45881b514b4SGreg Roach 'language-uz' => LanguageUzbek::class, 45902086832SGreg Roach 'language-vi' => LanguageVietnamese::class, 46002086832SGreg Roach 'language-yi' => LanguageYiddish::class, 46102086832SGreg Roach 'language-zh-Hans' => LanguageChineseSimplified::class, 46202086832SGreg Roach 'language-zh-Hant' => LanguageChineseTraditional::class, 46355134edcSGreg Roach 'legacy-urls' => RedirectLegacyUrlsModule::class, 4644ca7e03cSGreg Roach 'lifespans_chart' => LifespansChartModule::class, 4654ca7e03cSGreg Roach 'lightbox' => AlbumModule::class, 4664ca7e03cSGreg Roach 'lists-menu' => ListsMenuModule::class, 467e8ded2caSGreg Roach 'location_list' => LocationListModule::class, 4684ca7e03cSGreg Roach 'logged_in' => LoggedInUsersModule::class, 4694ca7e03cSGreg Roach 'login_block' => LoginBlockModule::class, 47082be4a69SGreg Roach 'low_countries_rulers' => LowCountriesRulers::class, 471c9c6f2ecSGreg Roach 'map-link-bing' => MapLinkBing::class, 472c9c6f2ecSGreg Roach 'map-link-google' => MapLinkGoogle::class, 473c9c6f2ecSGreg Roach 'map-link-openstreetmap' => MapLinkOpenStreetMap::class, 474c9c6f2ecSGreg Roach 'map-location-geonames' => MapGeoLocationGeonames::class, 475c9c6f2ecSGreg Roach 'map-location-nominatim' => MapGeoLocationNominatim::class, 476c9c6f2ecSGreg Roach 'map-location-ors' => MapGeoLocationOpenRouteService::class, 477c9c6f2ecSGreg Roach 'mapbox' => MapBox::class, 4784ca7e03cSGreg Roach 'marriage_report' => MarriageReportModule::class, 4794ca7e03cSGreg Roach 'matomo-analytics' => MatomoAnalyticsModule::class, 4804ca7e03cSGreg Roach 'media' => MediaTabModule::class, 48167992b6aSRichard Cissee 'media_list' => MediaListModule::class, 4824ca7e03cSGreg Roach 'minimal' => MinimalTheme::class, 4834ca7e03cSGreg Roach 'missing_facts_report' => MissingFactsReportModule::class, 4844ca7e03cSGreg Roach 'notes' => NotesTabModule::class, 48567992b6aSRichard Cissee 'note_list' => NoteListModule::class, 486*14974d95SRAMINCNZ 'nz-leaders' => NewZealandPrimeMinisters::class, 4874ca7e03cSGreg Roach 'occupation_report' => OccupationReportModule::class, 488c9c6f2ecSGreg Roach 'openrouteservice' => OpenRouteServiceAutocomplete::class, 489c9c6f2ecSGreg Roach 'openstreetmap' => OpenStreetMap::class, 4904ca7e03cSGreg Roach 'pedigree-map' => PedigreeMapModule::class, 4914ca7e03cSGreg Roach 'pedigree_chart' => PedigreeChartModule::class, 4924ca7e03cSGreg Roach 'pedigree_report' => PedigreeReportModule::class, 4934ca7e03cSGreg Roach 'personal_facts' => IndividualFactsTabModule::class, 4944ca7e03cSGreg Roach 'places' => PlacesModule::class, 49567992b6aSRichard Cissee 'places_list' => PlaceHierarchyListModule::class, 4964ca7e03cSGreg Roach 'powered-by-webtrees' => PoweredByWebtreesModule::class, 497b3a775f6SGreg Roach 'privacy-policy' => PrivacyPolicy::class, 4984ca7e03cSGreg Roach 'random_media' => SlideShowModule::class, 4994ca7e03cSGreg Roach 'recent_changes' => RecentChangesModule::class, 5004ca7e03cSGreg Roach 'relationships_chart' => RelationshipsChartModule::class, 5014ca7e03cSGreg Roach 'relative_ext_report' => RelatedIndividualsReportModule::class, 5024ca7e03cSGreg Roach 'relatives' => RelativesTabModule::class, 5034ca7e03cSGreg Roach 'reports-menu' => ReportsMenuModule::class, 50467992b6aSRichard Cissee 'repository_list' => RepositoryListModule::class, 5054ca7e03cSGreg Roach 'review_changes' => ReviewChangesModule::class, 5064ca7e03cSGreg Roach 'search-menu' => SearchMenuModule::class, 507354a9dbaSGreg Roach 'share-anniversary' => ShareAnniversaryModule::class, 508853f2b8aSGreg Roach 'share-url' => ShareUrlModule::class, 5094ca7e03cSGreg Roach 'sitemap' => SiteMapModule::class, 51067992b6aSRichard Cissee 'source_list' => SourceListModule::class, 5114ca7e03cSGreg Roach 'sources_tab' => SourcesTabModule::class, 5124ca7e03cSGreg Roach 'statcounter' => StatcounterModule::class, 5134ca7e03cSGreg Roach 'statistics_chart' => StatisticsChartModule::class, 5144ca7e03cSGreg Roach 'stories' => StoriesModule::class, 515e72c24d6SGreg Roach 'submitter_list' => SubmitterListModule::class, 5164ca7e03cSGreg Roach 'theme_select' => ThemeSelectModule::class, 5174ca7e03cSGreg Roach 'timeline_chart' => TimelineChartModule::class, 5184ca7e03cSGreg Roach 'todays_events' => OnThisDayModule::class, 5194ca7e03cSGreg Roach 'todo' => ResearchTaskModule::class, 5204ca7e03cSGreg Roach 'top10_givnnames' => TopGivenNamesModule::class, 5214ca7e03cSGreg Roach 'top10_pageviews' => TopPageViewsModule::class, 5224ca7e03cSGreg Roach 'top10_surnames' => TopSurnamesModule::class, 5234ca7e03cSGreg Roach 'tree' => InteractiveTreeModule::class, 5244ca7e03cSGreg Roach 'trees-menu' => TreesMenuModule::class, 5254ca7e03cSGreg Roach 'upcoming_events' => UpcomingAnniversariesModule::class, 52609fbf3e5SGreg Roach 'us-presidents' => USPresidents::class, 5274ca7e03cSGreg Roach 'user_blog' => UserJournalModule::class, 5284ca7e03cSGreg Roach 'user_favorites' => UserFavoritesModule::class, 5294ca7e03cSGreg Roach 'user_messages' => UserMessagesModule::class, 5304ca7e03cSGreg Roach 'user_welcome' => UserWelcomeModule::class, 5314ca7e03cSGreg Roach 'webtrees' => WebtreesTheme::class, 5324ca7e03cSGreg Roach 'xenea' => XeneaTheme::class, 5334ca7e03cSGreg Roach 'yahrzeit' => YahrzeitModule::class, 5344ca7e03cSGreg Roach ]; 5354ca7e03cSGreg Roach 5364ca7e03cSGreg Roach /** 537dedcf571SGreg Roach * A function to convert modules into their titles - to create option lists, etc. 538dedcf571SGreg Roach * 539c6921a17SGreg Roach * @return Closure(ModuleInterface):string 540dedcf571SGreg Roach */ 541dedcf571SGreg Roach public function titleMapper(): Closure 542dedcf571SGreg Roach { 543f25fc0f9SGreg Roach return static fn (ModuleInterface $module): string => $module->title(); 544dedcf571SGreg Roach } 545dedcf571SGreg Roach 546dedcf571SGreg Roach /** 5474ca7e03cSGreg Roach * Modules which (a) provide a specific function and (b) we have permission to see. 5484ca7e03cSGreg Roach * 549ac19d600SGreg Roach * @template T of ModuleInterface 55047166c20SGreg Roach * 55147166c20SGreg Roach * @param class-string<T> $interface 5524ca7e03cSGreg Roach * @param Tree $tree 553e5a6b4d4SGreg Roach * @param UserInterface $user 5544ca7e03cSGreg Roach * 55547166c20SGreg Roach * @return Collection<int,T> 5564ca7e03cSGreg Roach */ 55787cca37cSGreg Roach public function findByComponent(string $interface, Tree $tree, UserInterface $user): Collection 5584ca7e03cSGreg Roach { 559b5979037SGreg Roach return $this->findByInterface($interface, false, true) 560f25fc0f9SGreg Roach ->filter(static fn (ModuleInterface $module): bool => $module->accessLevel($tree, $interface) >= Auth::accessLevel($tree, $user)); 5614ca7e03cSGreg Roach } 5624ca7e03cSGreg Roach 5634ca7e03cSGreg Roach /** 5644ca7e03cSGreg Roach * All modules which provide a specific function. 5654ca7e03cSGreg Roach * 566ac19d600SGreg Roach * @template T of ModuleInterface|MiddlewareInterface 56747166c20SGreg Roach * 56847166c20SGreg Roach * @param class-string<T> $interface 5694ca7e03cSGreg Roach * @param bool $include_disabled 570b5979037SGreg Roach * @param bool $sort 5714ca7e03cSGreg Roach * 572ac19d600SGreg Roach * @return Collection<int,T&ModuleInterface> 5734ca7e03cSGreg Roach */ 57477c72ee5SGreg Roach public function findByInterface(string $interface, bool $include_disabled = false, bool $sort = false): Collection 5754ca7e03cSGreg Roach { 576ac19d600SGreg Roach /** @var Collection<int,T&ModuleInterface> $modules */ 5779d627a9eSGreg Roach $modules = $this->all($include_disabled) 5789d627a9eSGreg Roach ->filter($this->interfaceFilter($interface)); 5794ca7e03cSGreg Roach 5804ca7e03cSGreg Roach switch ($interface) { 5814ca7e03cSGreg Roach case ModuleFooterInterface::class: 582ac19d600SGreg Roach /** @var Collection<int,T&ModuleInterface> */ 58337646143SGreg Roach return $modules->sort($this->footerComparator()); 5844ca7e03cSGreg Roach 5854ca7e03cSGreg Roach case ModuleMenuInterface::class: 586ac19d600SGreg Roach /** @var Collection<int,T&ModuleInterface> */ 58737646143SGreg Roach return $modules->sort($this->menuComparator()); 5884ca7e03cSGreg Roach 5894ca7e03cSGreg Roach case ModuleSidebarInterface::class: 590ac19d600SGreg Roach /** @var Collection<int,T&ModuleInterface> */ 59137646143SGreg Roach return $modules->sort($this->sidebarComparator()); 5924ca7e03cSGreg Roach 5934ca7e03cSGreg Roach case ModuleTabInterface::class: 594ac19d600SGreg Roach /** @var Collection<int,T&ModuleInterface> */ 59537646143SGreg Roach return $modules->sort($this->tabComparator()); 596b5979037SGreg Roach 597b5979037SGreg Roach default: 598b5979037SGreg Roach if ($sort) { 599ac19d600SGreg Roach /** @var Collection<int,T&ModuleInterface> */ 60037646143SGreg Roach return $modules->sort($this->moduleComparator()); 6014ca7e03cSGreg Roach } 6024ca7e03cSGreg Roach 6034ca7e03cSGreg Roach return $modules; 6044ca7e03cSGreg Roach } 605b5979037SGreg Roach } 6064ca7e03cSGreg Roach 6074ca7e03cSGreg Roach /** 6088d6560c4SGreg Roach * All modules. 6098d6560c4SGreg Roach * 6108d6560c4SGreg Roach * @param bool $include_disabled 6118d6560c4SGreg Roach * 61247166c20SGreg Roach * @return Collection<int,ModuleInterface> 6138d6560c4SGreg Roach */ 6148d6560c4SGreg Roach public function all(bool $include_disabled = false): Collection 6158d6560c4SGreg Roach { 6166b9cb339SGreg Roach return Registry::cache()->array()->remember('all-modules', function (): Collection { 6178d6560c4SGreg Roach // Modules have a default status, order etc. 6188d6560c4SGreg Roach // We can override these from database settings. 6198d6560c4SGreg Roach $module_info = DB::table('module') 6208d6560c4SGreg Roach ->get() 621f25fc0f9SGreg Roach ->mapWithKeys(static fn (object $row): array => [$row->module_name => $row]); 6228d6560c4SGreg Roach 6238d6560c4SGreg Roach return $this->coreModules() 6248d6560c4SGreg Roach ->merge($this->customModules()) 6250b5fd0a6SGreg Roach ->map(static function (ModuleInterface $module) use ($module_info): ModuleInterface { 6268d6560c4SGreg Roach $info = $module_info->get($module->name()); 6278d6560c4SGreg Roach 628f70bcff5SGreg Roach if (is_object($info)) { 6298d6560c4SGreg Roach $module->setEnabled($info->status === 'enabled'); 6308d6560c4SGreg Roach 6318d6560c4SGreg Roach if ($module instanceof ModuleFooterInterface && $info->footer_order !== null) { 6328d6560c4SGreg Roach $module->setFooterOrder((int) $info->footer_order); 6338d6560c4SGreg Roach } 6348d6560c4SGreg Roach 6358d6560c4SGreg Roach if ($module instanceof ModuleMenuInterface && $info->menu_order !== null) { 6368d6560c4SGreg Roach $module->setMenuOrder((int) $info->menu_order); 6378d6560c4SGreg Roach } 6388d6560c4SGreg Roach 6398d6560c4SGreg Roach if ($module instanceof ModuleSidebarInterface && $info->sidebar_order !== null) { 6408d6560c4SGreg Roach $module->setSidebarOrder((int) $info->sidebar_order); 6418d6560c4SGreg Roach } 6428d6560c4SGreg Roach 6438d6560c4SGreg Roach if ($module instanceof ModuleTabInterface && $info->tab_order !== null) { 6448d6560c4SGreg Roach $module->setTabOrder((int) $info->tab_order); 6458d6560c4SGreg Roach } 6468d6560c4SGreg Roach } else { 6478d6560c4SGreg Roach $module->setEnabled($module->isEnabledByDefault()); 6488d6560c4SGreg Roach 6498d6560c4SGreg Roach DB::table('module')->insert([ 6508d6560c4SGreg Roach 'module_name' => $module->name(), 6518d6560c4SGreg Roach 'status' => $module->isEnabled() ? 'enabled' : 'disabled', 6528d6560c4SGreg Roach ]); 6538d6560c4SGreg Roach } 6548d6560c4SGreg Roach 6558d6560c4SGreg Roach return $module; 6568d6560c4SGreg Roach }); 6578d6560c4SGreg Roach })->filter($this->enabledFilter($include_disabled)); 6588d6560c4SGreg Roach } 6598d6560c4SGreg Roach 6608d6560c4SGreg Roach /** 6618d6560c4SGreg Roach * All core modules in the system. 6628d6560c4SGreg Roach * 66347166c20SGreg Roach * @return Collection<int,ModuleInterface> 6648d6560c4SGreg Roach */ 6658d6560c4SGreg Roach private function coreModules(): Collection 6668d6560c4SGreg Roach { 6678d6560c4SGreg Roach return Collection::make(self::CORE_MODULES) 6680b5fd0a6SGreg Roach ->map(static function (string $class, string $name): ModuleInterface { 669d35568b4SGreg Roach $module = Registry::container()->get($class); 6708d6560c4SGreg Roach 6718d6560c4SGreg Roach $module->setName($name); 6728d6560c4SGreg Roach 6738d6560c4SGreg Roach return $module; 6748d6560c4SGreg Roach }); 6758d6560c4SGreg Roach } 6768d6560c4SGreg Roach 6778d6560c4SGreg Roach /** 6788d6560c4SGreg Roach * All custom modules in the system. Custom modules are defined in modules_v4/ 6798d6560c4SGreg Roach * 68047166c20SGreg Roach * @return Collection<int,ModuleCustomInterface> 6818d6560c4SGreg Roach */ 6828d6560c4SGreg Roach private function customModules(): Collection 6838d6560c4SGreg Roach { 684f397d0fdSGreg Roach $pattern = Webtrees::MODULES_DIR . '*/module.php'; 6858d6560c4SGreg Roach $filenames = glob($pattern, GLOB_NOSORT); 6868d6560c4SGreg Roach 6878d6560c4SGreg Roach return Collection::make($filenames) 6880b5fd0a6SGreg Roach ->filter(static function (string $filename): bool { 6898d6560c4SGreg Roach // Special characters will break PHP variable names. 6908d6560c4SGreg Roach // This also allows us to ignore modules called "foo.example" and "foo.disable" 6918d6560c4SGreg Roach $module_name = basename(dirname($filename)); 6928d6560c4SGreg Roach 693dec352c1SGreg Roach foreach (['.', ' ', '[', ']'] as $character) { 694dec352c1SGreg Roach if (str_contains($module_name, $character)) { 695dec352c1SGreg Roach return false; 696dec352c1SGreg Roach } 697dec352c1SGreg Roach } 698dec352c1SGreg Roach 699dec352c1SGreg Roach return strlen($module_name) <= 30; 7008d6560c4SGreg Roach }) 7011ff45046SGreg Roach ->map(static function (string $filename): ModuleCustomInterface|null { 7028d6560c4SGreg Roach $module = self::load($filename); 7038d6560c4SGreg Roach 7048d6560c4SGreg Roach if ($module instanceof ModuleCustomInterface) { 705a9866bf2SGreg Roach $module->setName('_' . basename(dirname($filename)) . '_'); 7068d6560c4SGreg Roach 7078d6560c4SGreg Roach return $module; 7088d6560c4SGreg Roach } 709a9866bf2SGreg Roach 710a9866bf2SGreg Roach return null; 7118d6560c4SGreg Roach }) 7128d6560c4SGreg Roach ->filter() 713f25fc0f9SGreg Roach ->mapWithKeys(static fn (ModuleCustomInterface $module): array => [$module->name() => $module]); 7148d6560c4SGreg Roach } 7158d6560c4SGreg Roach 7168d6560c4SGreg Roach /** 7175bc7939cSBen * Load a custom module in a static scope, to prevent it from modifying local or object variables. 7188d6560c4SGreg Roach */ 7191ff45046SGreg Roach private static function load(string $filename): ModuleInterface|null 7208d6560c4SGreg Roach { 7215bc7939cSBen try { 7228d6560c4SGreg Roach return include $filename; 723ad602e4bSGreg Roach } catch (Throwable $exception) { 7245bc7939cSBen $module_name = basename(dirname($filename)); 7254d7096d3SGreg Roach $message = 'Fatal error in module: ' . $module_name . '<br>' . $exception; 726ad602e4bSGreg Roach FlashMessages::addMessage($message, 'danger'); 7275bc7939cSBen } 728c9c6f2ecSGreg Roach 7295bc7939cSBen return null; 7308d6560c4SGreg Roach } 7318d6560c4SGreg Roach 7328d6560c4SGreg Roach /** 7338d6560c4SGreg Roach * A function filter modules by enabled/disabled 7348d6560c4SGreg Roach * 7358d6560c4SGreg Roach * @param bool $include_disabled 7368d6560c4SGreg Roach * 737c6921a17SGreg Roach * @return Closure(ModuleInterface):bool 7388d6560c4SGreg Roach */ 7398d6560c4SGreg Roach private function enabledFilter(bool $include_disabled): Closure 7408d6560c4SGreg Roach { 741f25fc0f9SGreg Roach return static fn (ModuleInterface $module): bool => $include_disabled || $module->isEnabled(); 7428d6560c4SGreg Roach } 7438d6560c4SGreg Roach 7448d6560c4SGreg Roach /** 7458d6560c4SGreg Roach * A function filter modules by type 7468d6560c4SGreg Roach * 747ac19d600SGreg Roach * @template T of ModuleInterface|MiddlewareInterface 748ac19d600SGreg Roach * 749ac19d600SGreg Roach * @param class-string<T> $interface 7508d6560c4SGreg Roach * 751c6921a17SGreg Roach * @return Closure(ModuleInterface):bool 7528d6560c4SGreg Roach */ 7538d6560c4SGreg Roach private function interfaceFilter(string $interface): Closure 7548d6560c4SGreg Roach { 755f25fc0f9SGreg Roach return static fn (ModuleInterface $module): bool => $module instanceof $interface; 7568d6560c4SGreg Roach } 7578d6560c4SGreg Roach 7588d6560c4SGreg Roach /** 7598d6560c4SGreg Roach * A function to sort footers 7608d6560c4SGreg Roach * 761c6921a17SGreg Roach * @return Closure(ModuleFooterInterface,ModuleFooterInterface):int 7628d6560c4SGreg Roach */ 76337646143SGreg Roach private function footerComparator(): Closure 7648d6560c4SGreg Roach { 765f25fc0f9SGreg Roach return static fn (ModuleFooterInterface $x, ModuleFooterInterface $y): int => $x->getFooterOrder() <=> $y->getFooterOrder(); 7668d6560c4SGreg Roach } 7678d6560c4SGreg Roach 7688d6560c4SGreg Roach /** 7698d6560c4SGreg Roach * A function to sort menus 7708d6560c4SGreg Roach * 771c6921a17SGreg Roach * @return Closure(ModuleMenuInterface,ModuleMenuInterface):int 7728d6560c4SGreg Roach */ 77337646143SGreg Roach private function menuComparator(): Closure 7748d6560c4SGreg Roach { 775f25fc0f9SGreg Roach return static fn (ModuleMenuInterface $x, ModuleMenuInterface $y): int => $x->getMenuOrder() <=> $y->getMenuOrder(); 7768d6560c4SGreg Roach } 7778d6560c4SGreg Roach 7788d6560c4SGreg Roach /** 779c6921a17SGreg Roach * A function to sort sidebars 7808d6560c4SGreg Roach * 781c6921a17SGreg Roach * @return Closure(ModuleSidebarInterface,ModuleSidebarInterface):int 7828d6560c4SGreg Roach */ 78337646143SGreg Roach private function sidebarComparator(): Closure 7848d6560c4SGreg Roach { 785f25fc0f9SGreg Roach return static fn (ModuleSidebarInterface $x, ModuleSidebarInterface $y): int => $x->getSidebarOrder() <=> $y->getSidebarOrder(); 7868d6560c4SGreg Roach } 7878d6560c4SGreg Roach 7888d6560c4SGreg Roach /** 789c6921a17SGreg Roach * A function to sort tabs 7908d6560c4SGreg Roach * 791c6921a17SGreg Roach * @return Closure(ModuleTabInterface,ModuleTabInterface):int 7928d6560c4SGreg Roach */ 79337646143SGreg Roach private function tabComparator(): Closure 7948d6560c4SGreg Roach { 795f25fc0f9SGreg Roach return static fn (ModuleTabInterface $x, ModuleTabInterface $y): int => $x->getTabOrder() <=> $y->getTabOrder(); 7968d6560c4SGreg Roach } 7978d6560c4SGreg Roach 7988d6560c4SGreg Roach /** 79902086832SGreg Roach * A function to sort modules by name. 80002086832SGreg Roach * 80102086832SGreg Roach * Languages have a "sortable" name, so that "British English" sorts as "English, British". 80202086832SGreg Roach * This provides a more natural order in the language menu. 8038d6560c4SGreg Roach * 804c6921a17SGreg Roach * @return Closure(ModuleInterface,ModuleInterface):int 8058d6560c4SGreg Roach */ 80637646143SGreg Roach private function moduleComparator(): Closure 8078d6560c4SGreg Roach { 8086c2179e2SGreg Roach return static function (ModuleInterface $x, ModuleInterface $y): int { 80902086832SGreg Roach $title1 = $x instanceof ModuleLanguageInterface ? $x->locale()->endonymSortable() : $x->title(); 81002086832SGreg Roach $title2 = $y instanceof ModuleLanguageInterface ? $y->locale()->endonymSortable() : $y->title(); 81102086832SGreg Roach 81237646143SGreg Roach return I18N::comparator()($title1, $title2); 8138d6560c4SGreg Roach }; 8148d6560c4SGreg Roach } 8158d6560c4SGreg Roach 8168d6560c4SGreg Roach /** 817c9c6f2ecSGreg Roach * During setup, we'll need access to some languages. 818c9c6f2ecSGreg Roach * 81947166c20SGreg Roach * @return Collection<int,ModuleLanguageInterface> 820c9c6f2ecSGreg Roach */ 821c9c6f2ecSGreg Roach public function setupLanguages(): Collection 822c9c6f2ecSGreg Roach { 823c9c6f2ecSGreg Roach return $this->coreModules() 824f25fc0f9SGreg Roach ->filter(static fn (ModuleInterface $module): bool => $module instanceof ModuleLanguageInterface && $module->isEnabledByDefault()) 825f25fc0f9SGreg Roach ->sort(static fn (ModuleLanguageInterface $x, ModuleLanguageInterface $y): int => $x->locale()->endonymSortable() <=> $y->locale()->endonymSortable()); 826c9c6f2ecSGreg Roach } 827c9c6f2ecSGreg Roach 828c9c6f2ecSGreg Roach /** 8294ca7e03cSGreg Roach * Find a specified module, if it is currently active. 8304ca7e03cSGreg Roach */ 8311ff45046SGreg Roach public function findByName(string $module_name, bool $include_disabled = false): ModuleInterface|null 8324ca7e03cSGreg Roach { 8339d627a9eSGreg Roach return $this->all($include_disabled) 834f25fc0f9SGreg Roach ->first(static fn (ModuleInterface $module): bool => $module->name() === $module_name); 8354ca7e03cSGreg Roach } 836bf57b580SGreg Roach 837bf57b580SGreg Roach /** 838bf57b580SGreg Roach * Configuration settings are available through the various "module component" pages. 839bf57b580SGreg Roach * For modules that do not provide a component, we need to list them separately. 840bf57b580SGreg Roach * 84109fbf3e5SGreg Roach * @param bool $include_disabled 84209fbf3e5SGreg Roach * 84347166c20SGreg Roach * @return Collection<int,ModuleInterface> 844bf57b580SGreg Roach */ 84509fbf3e5SGreg Roach public function otherModules(bool $include_disabled = false): Collection 846bf57b580SGreg Roach { 847abafa13cSGreg Roach return $this->findByInterface(ModuleInterface::class, $include_disabled, true) 8480b5fd0a6SGreg Roach ->filter(static function (ModuleInterface $module): bool { 849bf57b580SGreg Roach foreach (self::COMPONENTS as $interface) { 850bf57b580SGreg Roach if ($module instanceof $interface) { 851bf57b580SGreg Roach return false; 852bf57b580SGreg Roach } 853bf57b580SGreg Roach } 854bf57b580SGreg Roach 855bf57b580SGreg Roach return true; 856bf57b580SGreg Roach }); 857bf57b580SGreg Roach } 858bf57b580SGreg Roach 859bf57b580SGreg Roach /** 860bf57b580SGreg Roach * Generate a list of module names which exist in the database but not on disk. 861bf57b580SGreg Roach * 86236779af1SGreg Roach * @return Collection<int,string> 863bf57b580SGreg Roach */ 864bf57b580SGreg Roach public function deletedModules(): Collection 865bf57b580SGreg Roach { 866bf57b580SGreg Roach $database_modules = DB::table('module')->pluck('module_name'); 867bf57b580SGreg Roach 868d5d58984SGreg Roach $disk_modules = $this->all(true) 869f25fc0f9SGreg Roach ->map(static fn (ModuleInterface $module): string => $module->name()); 870bf57b580SGreg Roach 871bf57b580SGreg Roach return $database_modules->diff($disk_modules); 872bf57b580SGreg Roach } 87371378461SGreg Roach 87471378461SGreg Roach /** 87571378461SGreg Roach * Boot all the modules. 87671378461SGreg Roach * 87771378461SGreg Roach * @param ModuleThemeInterface $current_theme 87871378461SGreg Roach */ 879c81b7bf1SGreg Roach public function bootModules(ModuleThemeInterface $current_theme): void 880c81b7bf1SGreg Roach { 8819e18e23bSGreg Roach foreach ($this->all() as $module) { 88271378461SGreg Roach // Only bootstrap the current theme. 88371378461SGreg Roach if ($module instanceof ModuleThemeInterface && $module !== $current_theme) { 88471378461SGreg Roach continue; 88571378461SGreg Roach } 88671378461SGreg Roach 8879e18e23bSGreg Roach $module->boot(); 88871378461SGreg Roach } 88971378461SGreg Roach } 890745968f0SGreg Roach 891745968f0SGreg Roach /** 89236779af1SGreg Roach * @return Collection<int,string> 893745968f0SGreg Roach */ 8949f667ff2SGreg Roach public function componentsWithAccess(): Collection 895745968f0SGreg Roach { 8969f667ff2SGreg Roach return new Collection(self::COMPONENTS_WITH_ACCESS); 897745968f0SGreg Roach } 898745968f0SGreg Roach 899745968f0SGreg Roach /** 90036779af1SGreg Roach * @return Collection<int,string> 901745968f0SGreg Roach */ 9029f667ff2SGreg Roach public function componentsWithOrder(): Collection 903745968f0SGreg Roach { 9049f667ff2SGreg Roach return new Collection(self::COMPONENTS_WITH_SORT); 905745968f0SGreg Roach } 9064ca7e03cSGreg Roach} 907