Skip to content

Commit 8ea4d05

Browse files
committed
Fix: Module Registration plugin was not considering the dynamic app path.
1 parent 5080322 commit 8ea4d05

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Modules.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ public function getModule(string $name): \Nwidart\Modules\Module
1919
public function convertPathToNamespace(string $fullPath): string
2020
{
2121
$appFolder = trim(config('modules.paths.app_folder', 'app'), '/\\');
22+
$appPath = $appFolder . DIRECTORY_SEPARATOR;
2223
$base = str(trim(config('modules.paths.modules', base_path('Modules')), '/\\'));
23-
$relative = str($fullPath)->afterLast($base)->replaceFirst(DIRECTORY_SEPARATOR . $appFolder . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR);
24+
$replacementPath = str_replace(DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR, '/', DIRECTORY_SEPARATOR . $appPath);
25+
$relative = str($fullPath)->afterLast($base)->replaceFirst($replacementPath, DIRECTORY_SEPARATOR);
2426

2527
return str($relative)
2628
->ltrim('/\\')

src/ModulesPlugin.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ protected function getModulePlugins(): array
4545
}
4646
// get a glob of all Filament plugins
4747
$basePath = str(config('modules.paths.modules', 'Modules'));
48-
$pattern = $basePath . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'Filament' . DIRECTORY_SEPARATOR . '*Plugin.php';
48+
$appFolder = trim(config('modules.paths.app_folder', 'app'), '/\\');
49+
$appPath = $appFolder . DIRECTORY_SEPARATOR;
50+
$pattern = $basePath . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . $appPath . 'Filament' . DIRECTORY_SEPARATOR . '*Plugin.php';
4951
$pluginPaths = glob($pattern);
5052

5153
return collect($pluginPaths)->map(fn ($path) => FilamentModules::convertPathToNamespace($path))->toArray();

0 commit comments

Comments
 (0)