From b60b8be8548fd88c8efdec6cfe309d196593f752 Mon Sep 17 00:00:00 2001 From: Marcel Folaron Date: Fri, 16 Aug 2024 16:50:03 -0400 Subject: [PATCH] update event cache to include check for debug --- app/Core/Events.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) 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 *