File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed
Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -160,4 +160,33 @@ protected function write(array $manifest)
160160 '<?php return ' .var_export ($ manifest , true ).'; '
161161 );
162162 }
163+
164+ public function registerFiles (): void
165+ {
166+ //todo check this section store on module.php or not?
167+ $ this ->paths
168+ ->flatMap (function ($ path ) {
169+ $ manifests = $ this ->files ->glob ("{$ path }/module.json " );
170+ is_array ($ manifests ) || $ manifests = [];
171+
172+ return collect ($ manifests )
173+ ->map (function ($ manifest ) {
174+ $ json = $ this ->files ->json ($ manifest );
175+
176+ if (! empty ($ json ['files ' ])) {
177+ return [
178+ 'module_directory ' => dirname ($ manifest ),
179+ ...$ this ->files ->json ($ manifest ),
180+ ];
181+ }
182+ });
183+ })
184+ ->filter ()
185+ ->sortBy (fn ($ module ) => $ module ['priority ' ] ?? 0 )
186+ ->each (function (array $ manifest ) {
187+ foreach ($ manifest ['files ' ] as $ file ) {
188+ include_once $ manifest ['module_directory ' ].DIRECTORY_SEPARATOR .$ file ;
189+ }
190+ });
191+ }
163192}
Original file line number Diff line number Diff line change @@ -28,10 +28,12 @@ protected function registerModules()
2828 {
2929 // $this->app->register(\Nwidart\Modules\Providers\BootstrapServiceProvider::class);
3030
31- $ providers = app ()->make (ModuleManifest::class)-> providersArray ( );
31+ $ manifest = app ()->make (ModuleManifest::class);
3232
33- (new ProviderRepository ($ this ->app , new Filesystem (), $ this ->getCachedModulePath ()))
34- ->load ($ providers );
33+ (new ProviderRepository ($ this ->app , new Filesystem , $ this ->getCachedModulePath ()))
34+ ->load ($ manifest ->providersArray ());
35+
36+ $ manifest ->registerFiles ();
3537
3638 }
3739
You can’t perform that action at this time.
0 commit comments