diff --git a/app/Core/Events.php b/app/Core/Events.php index d6b53c9e2b..f75e323fea 100644 --- a/app/Core/Events.php +++ b/app/Core/Events.php @@ -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")) { @@ -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 *