From a345e00f535e76f485b2e0a40f27551b990b5519 Mon Sep 17 00:00:00 2001 From: benatoff <146389211+benatoff@users.noreply.github.com> Date: Thu, 5 Dec 2024 21:39:34 +0100 Subject: [PATCH] [5.x] Register App extensions also for Classes in Subfolders (#11046) Co-authored-by: Duncan McClean --- src/Providers/ExtensionServiceProvider.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Providers/ExtensionServiceProvider.php b/src/Providers/ExtensionServiceProvider.php index d70ffa149f..2a32a74bc2 100644 --- a/src/Providers/ExtensionServiceProvider.php +++ b/src/Providers/ExtensionServiceProvider.php @@ -335,9 +335,12 @@ protected function registerAppExtensions($folder, $requiredClass) return; } - foreach ($this->app['files']->files($path) as $file) { + foreach ($this->app['files']->allFiles($path) as $file) { + $relativePathOfFolder = str_replace(app_path('/'), '', $file->getPath()); + $namespace = str_replace('/', '\\', $relativePathOfFolder); $class = $file->getBasename('.php'); - $fqcn = $this->app->getNamespace()."{$folder}\\{$class}"; + + $fqcn = $this->app->getNamespace()."{$namespace}\\{$class}"; if (is_subclass_of($fqcn, $requiredClass)) { $fqcn::register(); }