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\Services; 19 20use Closure; 21use Fisharebest\Webtrees\Auth; 22use Fisharebest\Webtrees\Contracts\UserInterface; 23use Fisharebest\Webtrees\FlashMessages; 24use Fisharebest\Webtrees\I18N; 25use Fisharebest\Webtrees\Module\AhnentafelReportModule; 26use Fisharebest\Webtrees\Module\AlbumModule; 27use Fisharebest\Webtrees\Module\AncestorsChartModule; 28use Fisharebest\Webtrees\Module\BatchUpdateModule; 29use Fisharebest\Webtrees\Module\BingWebmasterToolsModule; 30use Fisharebest\Webtrees\Module\BirthDeathMarriageReportModule; 31use Fisharebest\Webtrees\Module\BirthReportModule; 32use Fisharebest\Webtrees\Module\BranchesListModule; 33use Fisharebest\Webtrees\Module\BritishMonarchs; 34use Fisharebest\Webtrees\Module\BritishPrimeMinisters; 35use Fisharebest\Webtrees\Module\BritishSocialHistory; 36use Fisharebest\Webtrees\Module\CalendarMenuModule; 37use Fisharebest\Webtrees\Module\CemeteryReportModule; 38use Fisharebest\Webtrees\Module\CensusAssistantModule; 39use Fisharebest\Webtrees\Module\ChangeReportModule; 40use Fisharebest\Webtrees\Module\ChartsBlockModule; 41use Fisharebest\Webtrees\Module\ChartsMenuModule; 42use Fisharebest\Webtrees\Module\CkeditorModule; 43use Fisharebest\Webtrees\Module\ClippingsCartModule; 44use Fisharebest\Webtrees\Module\CloudsTheme; 45use Fisharebest\Webtrees\Module\ColorsTheme; 46use Fisharebest\Webtrees\Module\CompactTreeChartModule; 47use Fisharebest\Webtrees\Module\ContactsFooterModule; 48use Fisharebest\Webtrees\Module\CookieWarningModule; 49use Fisharebest\Webtrees\Module\DeathReportModule; 50use Fisharebest\Webtrees\Module\DescendancyChartModule; 51use Fisharebest\Webtrees\Module\DescendancyModule; 52use Fisharebest\Webtrees\Module\DescendancyReportModule; 53use Fisharebest\Webtrees\Module\FabTheme; 54use Fisharebest\Webtrees\Module\FactSourcesReportModule; 55use Fisharebest\Webtrees\Module\FamilyBookChartModule; 56use Fisharebest\Webtrees\Module\FamilyGroupReportModule; 57use Fisharebest\Webtrees\Module\FamilyListModule; 58use Fisharebest\Webtrees\Module\FamilyNavigatorModule; 59use Fisharebest\Webtrees\Module\FamilyTreeFavoritesModule; 60use Fisharebest\Webtrees\Module\FamilyTreeNewsModule; 61use Fisharebest\Webtrees\Module\FamilyTreeStatisticsModule; 62use Fisharebest\Webtrees\Module\FanChartModule; 63use Fisharebest\Webtrees\Module\FrequentlyAskedQuestionsModule; 64use Fisharebest\Webtrees\Module\GoogleAnalyticsModule; 65use Fisharebest\Webtrees\Module\GoogleWebmasterToolsModule; 66use Fisharebest\Webtrees\Module\HitCountFooterModule; 67use Fisharebest\Webtrees\Module\HourglassChartModule; 68use Fisharebest\Webtrees\Module\HtmlBlockModule; 69use Fisharebest\Webtrees\Module\IndividualFactsTabModule; 70use Fisharebest\Webtrees\Module\IndividualFamiliesReportModule; 71use Fisharebest\Webtrees\Module\IndividualListModule; 72use Fisharebest\Webtrees\Module\IndividualMetadataModule; 73use Fisharebest\Webtrees\Module\IndividualReportModule; 74use Fisharebest\Webtrees\Module\InteractiveTreeModule; 75use Fisharebest\Webtrees\Module\LifespansChartModule; 76use Fisharebest\Webtrees\Module\ListsMenuModule; 77use Fisharebest\Webtrees\Module\LoggedInUsersModule; 78use Fisharebest\Webtrees\Module\LoginBlockModule; 79use Fisharebest\Webtrees\Module\MarriageReportModule; 80use Fisharebest\Webtrees\Module\MatomoAnalyticsModule; 81use Fisharebest\Webtrees\Module\MediaListModule; 82use Fisharebest\Webtrees\Module\MediaTabModule; 83use Fisharebest\Webtrees\Module\MinimalTheme; 84use Fisharebest\Webtrees\Module\MissingFactsReportModule; 85use Fisharebest\Webtrees\Module\ModuleAnalyticsInterface; 86use Fisharebest\Webtrees\Module\ModuleBlockInterface; 87use Fisharebest\Webtrees\Module\ModuleChartInterface; 88use Fisharebest\Webtrees\Module\ModuleConfigInterface; 89use Fisharebest\Webtrees\Module\ModuleCustomInterface; 90use Fisharebest\Webtrees\Module\ModuleFooterInterface; 91use Fisharebest\Webtrees\Module\ModuleHistoricEventsInterface; 92use Fisharebest\Webtrees\Module\ModuleInterface; 93use Fisharebest\Webtrees\Module\ModuleLanguageInterface; 94use Fisharebest\Webtrees\Module\ModuleListInterface; 95use Fisharebest\Webtrees\Module\ModuleMenuInterface; 96use Fisharebest\Webtrees\Module\ModuleReportInterface; 97use Fisharebest\Webtrees\Module\ModuleSidebarInterface; 98use Fisharebest\Webtrees\Module\ModuleTabInterface; 99use Fisharebest\Webtrees\Module\ModuleThemeInterface; 100use Fisharebest\Webtrees\Module\NoteListModule; 101use Fisharebest\Webtrees\Module\NotesTabModule; 102use Fisharebest\Webtrees\Module\OccupationReportModule; 103use Fisharebest\Webtrees\Module\OnThisDayModule; 104use Fisharebest\Webtrees\Module\PedigreeChartModule; 105use Fisharebest\Webtrees\Module\PedigreeMapModule; 106use Fisharebest\Webtrees\Module\PedigreeReportModule; 107use Fisharebest\Webtrees\Module\PlaceHierarchyListModule; 108use Fisharebest\Webtrees\Module\PlacesModule; 109use Fisharebest\Webtrees\Module\PoweredByWebtreesModule; 110use Fisharebest\Webtrees\Module\RecentChangesModule; 111use Fisharebest\Webtrees\Module\RelatedIndividualsReportModule; 112use Fisharebest\Webtrees\Module\RelationshipsChartModule; 113use Fisharebest\Webtrees\Module\RelativesTabModule; 114use Fisharebest\Webtrees\Module\ReportsMenuModule; 115use Fisharebest\Webtrees\Module\RepositoryListModule; 116use Fisharebest\Webtrees\Module\ResearchTaskModule; 117use Fisharebest\Webtrees\Module\ReviewChangesModule; 118use Fisharebest\Webtrees\Module\SearchMenuModule; 119use Fisharebest\Webtrees\Module\SiteMapModule; 120use Fisharebest\Webtrees\Module\SlideShowModule; 121use Fisharebest\Webtrees\Module\SourceListModule; 122use Fisharebest\Webtrees\Module\SourcesTabModule; 123use Fisharebest\Webtrees\Module\StatcounterModule; 124use Fisharebest\Webtrees\Module\StatisticsChartModule; 125use Fisharebest\Webtrees\Module\StoriesModule; 126use Fisharebest\Webtrees\Module\ThemeSelectModule; 127use Fisharebest\Webtrees\Module\TimelineChartModule; 128use Fisharebest\Webtrees\Module\TopGivenNamesModule; 129use Fisharebest\Webtrees\Module\TopPageViewsModule; 130use Fisharebest\Webtrees\Module\TopSurnamesModule; 131use Fisharebest\Webtrees\Module\TreesMenuModule; 132use Fisharebest\Webtrees\Module\UpcomingAnniversariesModule; 133use Fisharebest\Webtrees\Module\UserFavoritesModule; 134use Fisharebest\Webtrees\Module\UserJournalModule; 135use Fisharebest\Webtrees\Module\UserMessagesModule; 136use Fisharebest\Webtrees\Module\UserWelcomeModule; 137use Fisharebest\Webtrees\Module\USPresidents; 138use Fisharebest\Webtrees\Module\WebtreesTheme; 139use Fisharebest\Webtrees\Module\WelcomeBlockModule; 140use Fisharebest\Webtrees\Module\XeneaTheme; 141use Fisharebest\Webtrees\Module\YahrzeitModule; 142use Fisharebest\Webtrees\Tree; 143use Fisharebest\Webtrees\Webtrees; 144use Illuminate\Database\Capsule\Manager as DB; 145use Illuminate\Support\Collection; 146use Illuminate\Support\Str; 147use stdClass; 148use Throwable; 149 150/** 151 * Functions for managing and maintaining modules. 152 */ 153class ModuleService 154{ 155 // Components are pieces of user-facing functionality, are managed together in the control panel. 156 private const COMPONENTS = [ 157 ModuleAnalyticsInterface::class, 158 ModuleBlockInterface::class, 159 ModuleChartInterface::class, 160 ModuleFooterInterface::class, 161 ModuleHistoricEventsInterface::class, 162 ModuleLanguageInterface::class, 163 ModuleListInterface::class, 164 ModuleMenuInterface::class, 165 ModuleReportInterface::class, 166 ModuleSidebarInterface::class, 167 ModuleTabInterface::class, 168 ModuleThemeInterface::class, 169 ]; 170 171 // Array keys are module names, and should match module names from earlier versions of webtrees. 172 private const CORE_MODULES = [ 173 'GEDFact_assistant' => CensusAssistantModule::class, 174 'ahnentafel_report' => AhnentafelReportModule::class, 175 'ancestors_chart' => AncestorsChartModule::class, 176 'batch_update' => BatchUpdateModule::class, 177 'bdm_report' => BirthDeathMarriageReportModule::class, 178 'bing-webmaster-tools' => BingWebmasterToolsModule::class, 179 'birth_report' => BirthReportModule::class, 180 'branches_list' => BranchesListModule::class, 181 'british-monarchs' => BritishMonarchs::class, 182 'british-prime-ministers' => BritishPrimeMinisters::class, 183 'british-social-history' => BritishSocialHistory::class, 184 'calendar-menu' => CalendarMenuModule::class, 185 'cemetery_report' => CemeteryReportModule::class, 186 'change_report' => ChangeReportModule::class, 187 'charts' => ChartsBlockModule::class, 188 'charts-menu' => ChartsMenuModule::class, 189 'ckeditor' => CkeditorModule::class, 190 'clippings' => ClippingsCartModule::class, 191 'clouds' => CloudsTheme::class, 192 'colors' => ColorsTheme::class, 193 'compact-chart' => CompactTreeChartModule::class, 194 'contact-links' => ContactsFooterModule::class, 195 'cookie-warning' => CookieWarningModule::class, 196 'death_report' => DeathReportModule::class, 197 'descendancy' => DescendancyModule::class, 198 'descendancy_chart' => DescendancyChartModule::class, 199 'descendancy_report' => DescendancyReportModule::class, 200 'extra_info' => IndividualMetadataModule::class, 201 'fab' => FabTheme::class, 202 'fact_sources' => FactSourcesReportModule::class, 203 'family_book_chart' => FamilyBookChartModule::class, 204 'family_group_report' => FamilyGroupReportModule::class, 205 'family_list' => FamilyListModule::class, 206 'family_nav' => FamilyNavigatorModule::class, 207 'fan_chart' => FanChartModule::class, 208 'faq' => FrequentlyAskedQuestionsModule::class, 209 'gedcom_block' => WelcomeBlockModule::class, 210 'gedcom_favorites' => FamilyTreeFavoritesModule::class, 211 'gedcom_news' => FamilyTreeNewsModule::class, 212 'gedcom_stats' => FamilyTreeStatisticsModule::class, 213 'google-analytics' => GoogleAnalyticsModule::class, 214 'google-webmaster-tools' => GoogleWebmasterToolsModule::class, 215 'hit-counter' => HitCountFooterModule::class, 216 'hourglass_chart' => HourglassChartModule::class, 217 'html' => HtmlBlockModule::class, 218 'individual_ext_report' => IndividualFamiliesReportModule::class, 219 'individual_list' => IndividualListModule::class, 220 'individual_report' => IndividualReportModule::class, 221 'lifespans_chart' => LifespansChartModule::class, 222 'lightbox' => AlbumModule::class, 223 'lists-menu' => ListsMenuModule::class, 224 'logged_in' => LoggedInUsersModule::class, 225 'login_block' => LoginBlockModule::class, 226 'marriage_report' => MarriageReportModule::class, 227 'matomo-analytics' => MatomoAnalyticsModule::class, 228 'media' => MediaTabModule::class, 229 'media_list' => MediaListModule::class, 230 'minimal' => MinimalTheme::class, 231 'missing_facts_report' => MissingFactsReportModule::class, 232 'notes' => NotesTabModule::class, 233 'note_list' => NoteListModule::class, 234 'occupation_report' => OccupationReportModule::class, 235 'pedigree-map' => PedigreeMapModule::class, 236 'pedigree_chart' => PedigreeChartModule::class, 237 'pedigree_report' => PedigreeReportModule::class, 238 'personal_facts' => IndividualFactsTabModule::class, 239 'places' => PlacesModule::class, 240 'places_list' => PlaceHierarchyListModule::class, 241 'powered-by-webtrees' => PoweredByWebtreesModule::class, 242 'random_media' => SlideShowModule::class, 243 'recent_changes' => RecentChangesModule::class, 244 'relationships_chart' => RelationshipsChartModule::class, 245 'relative_ext_report' => RelatedIndividualsReportModule::class, 246 'relatives' => RelativesTabModule::class, 247 'reports-menu' => ReportsMenuModule::class, 248 'repository_list' => RepositoryListModule::class, 249 'review_changes' => ReviewChangesModule::class, 250 'search-menu' => SearchMenuModule::class, 251 'sitemap' => SiteMapModule::class, 252 'source_list' => SourceListModule::class, 253 'sources_tab' => SourcesTabModule::class, 254 'statcounter' => StatcounterModule::class, 255 'statistics_chart' => StatisticsChartModule::class, 256 'stories' => StoriesModule::class, 257 'theme_select' => ThemeSelectModule::class, 258 'timeline_chart' => TimelineChartModule::class, 259 'todays_events' => OnThisDayModule::class, 260 'todo' => ResearchTaskModule::class, 261 'top10_givnnames' => TopGivenNamesModule::class, 262 'top10_pageviews' => TopPageViewsModule::class, 263 'top10_surnames' => TopSurnamesModule::class, 264 'tree' => InteractiveTreeModule::class, 265 'trees-menu' => TreesMenuModule::class, 266 'upcoming_events' => UpcomingAnniversariesModule::class, 267 'us-presidents' => USPresidents::class, 268 'user_blog' => UserJournalModule::class, 269 'user_favorites' => UserFavoritesModule::class, 270 'user_messages' => UserMessagesModule::class, 271 'user_welcome' => UserWelcomeModule::class, 272 'webtrees' => WebtreesTheme::class, 273 'xenea' => XeneaTheme::class, 274 'yahrzeit' => YahrzeitModule::class, 275 ]; 276 277 /** 278 * All core modules in the system. 279 * 280 * @return Collection 281 */ 282 private function coreModules(): Collection 283 { 284 return Collection::make(self::CORE_MODULES) 285 ->map(function (string $class, string $name): ModuleInterface { 286 $module = app($class); 287 288 $module->setName($name); 289 290 return $module; 291 }); 292 } 293 294 /** 295 * All custom modules in the system. Custom modules are defined in modules_v4/ 296 * 297 * @return Collection 298 */ 299 private function customModules(): Collection 300 { 301 $pattern = WT_ROOT . Webtrees::MODULES_PATH . '*/module.php'; 302 $filenames = glob($pattern); 303 304 return Collection::make($filenames) 305 ->filter(function (string $filename): bool { 306 // Special characters will break PHP variable names. 307 // This also allows us to ignore modules called "foo.example" and "foo.disable" 308 $module_name = basename(dirname($filename)); 309 310 return !Str::contains($module_name, ['.', ' ', '[', ']']) && Str::length($module_name) <= 30; 311 }) 312 ->map(function (string $filename): ?ModuleCustomInterface { 313 try { 314 $module = self::load($filename); 315 316 if ($module instanceof ModuleCustomInterface) { 317 $module_name = '_' . basename(dirname($filename)) . '_'; 318 319 $module->setName($module_name); 320 } else { 321 return null; 322 } 323 324 return $module; 325 } catch (Throwable $ex) { 326 $message = '<pre>' . e($ex->getMessage()) . "\n" . e($ex->getTraceAsString()) . '</pre>'; 327 FlashMessages::addMessage($message, 'danger'); 328 329 return null; 330 } 331 }) 332 ->filter(); 333 } 334 335 /** 336 * All modules. 337 * 338 * @param bool $include_disabled 339 * 340 * @return Collection|ModuleInterface[] 341 */ 342 public function all(bool $include_disabled = false): Collection 343 { 344 return app('cache.array')->rememberForever('all_modules', function (): Collection { 345 // Modules have a default status, order etc. 346 // We can override these from database settings. 347 $module_info = DB::table('module') 348 ->get() 349 ->mapWithKeys(function (stdClass $row): array { 350 return [$row->module_name => $row]; 351 }); 352 353 return $this->coreModules() 354 ->merge($this->customModules()) 355 ->map(function (ModuleInterface $module) use ($module_info): ModuleInterface { 356 $info = $module_info->get($module->name()); 357 358 if ($info instanceof stdClass) { 359 $module->setEnabled($info->status === 'enabled'); 360 361 if ($module instanceof ModuleFooterInterface && $info->footer_order !== null) { 362 $module->setFooterOrder((int) $info->footer_order); 363 } 364 365 if ($module instanceof ModuleMenuInterface && $info->menu_order !== null) { 366 $module->setMenuOrder((int) $info->menu_order); 367 } 368 369 if ($module instanceof ModuleSidebarInterface && $info->sidebar_order !== null) { 370 $module->setSidebarOrder((int) $info->sidebar_order); 371 } 372 373 if ($module instanceof ModuleTabInterface && $info->tab_order !== null) { 374 $module->setTabOrder((int) $info->tab_order); 375 } 376 } else { 377 $module->setEnabled($module->isEnabledByDefault()); 378 379 DB::table('module')->insert([ 380 'module_name' => $module->name(), 381 'status' => $module->isEnabled() ? 'enabled' : 'disabled', 382 ]); 383 } 384 385 return $module; 386 }); 387 })->filter($this->enabledFilter($include_disabled)); 388 } 389 390 /** 391 * Load a module in a static scope, to prevent it from modifying local or object variables. 392 * 393 * @param string $filename 394 * 395 * @return mixed 396 */ 397 private static function load(string $filename) 398 { 399 return include $filename; 400 } 401 402 /** 403 * A function to sort modules by name 404 * 405 * @return Closure 406 */ 407 private function moduleSorter(): Closure 408 { 409 return function (ModuleInterface $x, ModuleInterface $y): int { 410 return I18N::strcasecmp($x->title(), $y->title()); 411 }; 412 } 413 414 /** 415 * A function to sort footers 416 * 417 * @return Closure 418 */ 419 private function footerSorter(): Closure 420 { 421 return function (ModuleFooterInterface $x, ModuleFooterInterface $y): int { 422 return $x->getFooterOrder() <=> $y->getFooterOrder(); 423 }; 424 } 425 426 /** 427 * A function to sort menus 428 * 429 * @return Closure 430 */ 431 private function menuSorter(): Closure 432 { 433 return function (ModuleMenuInterface $x, ModuleMenuInterface $y): int { 434 return $x->getMenuOrder() <=> $y->getMenuOrder(); 435 }; 436 } 437 438 /** 439 * A function to sort menus 440 * 441 * @return Closure 442 */ 443 private function sidebarSorter(): Closure 444 { 445 return function (ModuleSidebarInterface $x, ModuleSidebarInterface $y): int { 446 return $x->getSidebarOrder() <=> $y->getSidebarOrder(); 447 }; 448 } 449 450 /** 451 * A function to sort menus 452 * 453 * @return Closure 454 */ 455 private function tabSorter(): Closure 456 { 457 return function (ModuleTabInterface $x, ModuleTabInterface $y): int { 458 return $x->getTabOrder() <=> $y->getTabOrder(); 459 }; 460 } 461 462 /** 463 * A function filter modules by type 464 * 465 * @param string $interface 466 * 467 * @return Closure 468 */ 469 private function interfaceFilter(string $interface): Closure 470 { 471 return function (ModuleInterface $module) use ($interface): bool { 472 return $module instanceof $interface; 473 }; 474 } 475 476 /** 477 * A function filter modules by enabled/disabled 478 * 479 * @param bool $include_disabled 480 * 481 * @return Closure 482 */ 483 private function enabledFilter(bool $include_disabled): Closure 484 { 485 return function (ModuleInterface $module) use ($include_disabled): bool { 486 return $include_disabled || $module->isEnabled(); 487 }; 488 } 489 490 /** 491 * A function to convert modules into their titles - to create option lists, etc. 492 * 493 * @return Closure 494 */ 495 public function titleMapper(): Closure 496 { 497 return function (ModuleInterface $module): string { 498 return $module->title(); 499 }; 500 } 501 502 /** 503 * Modules which (a) provide a specific function and (b) we have permission to see. 504 * 505 * @param string $interface 506 * @param Tree $tree 507 * @param UserInterface $user 508 * 509 * @return Collection|ModuleInterface[] 510 */ 511 public function findByComponent(string $interface, Tree $tree, UserInterface $user): Collection 512 { 513 return $this->findByInterface($interface, false, true) 514 ->filter(function (ModuleInterface $module) use ($interface, $tree, $user): bool { 515 return $module->accessLevel($tree, $interface) >= Auth::accessLevel($tree, $user); 516 }); 517 } 518 519 /** 520 * All modules which provide a specific function. 521 * 522 * @param string $interface 523 * @param bool $include_disabled 524 * @param bool $sort 525 * 526 * @return Collection|ModuleInterface[] 527 */ 528 public function findByInterface(string $interface, $include_disabled = false, $sort = false): Collection 529 { 530 $modules = $this->all($include_disabled) 531 ->filter($this->interfaceFilter($interface)); 532 533 switch ($interface) { 534 case ModuleFooterInterface::class: 535 return $modules->sort($this->footerSorter()); 536 537 case ModuleMenuInterface::class: 538 return $modules->sort($this->menuSorter()); 539 540 case ModuleSidebarInterface::class: 541 return $modules->sort($this->sidebarSorter()); 542 543 case ModuleTabInterface::class: 544 return $modules->sort($this->tabSorter()); 545 546 default: 547 if ($sort) { 548 return $modules->sort($this->moduleSorter()); 549 } 550 551 return $modules; 552 } 553 } 554 555 /** 556 * Find a specified module, if it is currently active. 557 * 558 * @param string $module_name 559 * @param bool $include_disabled 560 * 561 * @return ModuleInterface|null 562 */ 563 public function findByName(string $module_name, bool $include_disabled = false): ?ModuleInterface 564 { 565 return $this->all($include_disabled) 566 ->filter(function (ModuleInterface $module) use ($module_name): bool { 567 return $module->name() === $module_name; 568 }) 569 ->first(); 570 } 571 572 /** 573 * Configuration settings are available through the various "module component" pages. 574 * For modules that do not provide a component, we need to list them separately. 575 * 576 * @param bool $include_disabled 577 * 578 * @return Collection|ModuleConfigInterface[] 579 */ 580 public function otherModules(bool $include_disabled = false): Collection 581 { 582 return $this->all($include_disabled) 583 ->filter(function (ModuleInterface $module): bool { 584 foreach (self::COMPONENTS as $interface) { 585 if ($module instanceof $interface) { 586 return false; 587 } 588 } 589 590 return true; 591 }); 592 } 593 594 /** 595 * Generate a list of module names which exist in the database but not on disk. 596 * 597 * @return Collection|string[] 598 */ 599 public function deletedModules(): Collection 600 { 601 $database_modules = DB::table('module')->pluck('module_name'); 602 603 $disk_modules = $this->all(true) 604 ->map(function (ModuleInterface $module): string { 605 return $module->name(); 606 }); 607 608 return $database_modules->diff($disk_modules); 609 } 610} 611