Skip to content

Commit

Permalink
update event cache to include check for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Aug 16, 2024
1 parent 0323519 commit b60b8be
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions app/Core/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,14 @@ public static function discover_listeners(): void
return;
}

$modules = Cache::store('installation')->rememberForever('domainEvents', function () {
$customModules = collect(glob(APP_ROOT . '/custom/Domain' . '/*', GLOB_ONLYDIR));
$domainModules = collect(glob(APP_ROOT . "/app/Domain" . '/*', GLOB_ONLYDIR));
if(!config('debug')) {
$modules = Cache::store('installation')->rememberForever('domainEvents', function () {
return Events::getDomainPaths();
});

$testers = $customModules->map(fn ($path) => str_replace('/custom/', '/app/', $path));

$filteredModules = $domainModules->filter(fn ($path) => ! $testers->contains($path));

return $customModules->concat($filteredModules)->all();
});
}else{
$modules = self::getDomainPaths();
}

foreach ($modules as $module) {
if (file_exists($moduleEventsPath = "$module/register.php")) {
Expand Down Expand Up @@ -263,6 +261,18 @@ public static function discover_listeners(): void
$discovered = true;
}

public static function getDomainPaths() {

$customModules = collect(glob(APP_ROOT . '/custom/Domain' . '/*', GLOB_ONLYDIR));
$domainModules = collect(glob(APP_ROOT . "/app/Domain" . '/*', GLOB_ONLYDIR));

$testers = $customModules->map(fn ($path) => str_replace('/custom/', '/app/', $path));

$filteredModules = $domainModules->filter(fn ($path) => ! $testers->contains($path));

return $customModules->concat($filteredModules)->all();
}

/**
* Adds an event listener to be registered
*
Expand Down

0 comments on commit b60b8be

Please sign in to comment.