@@ -10,11 +10,6 @@ class WorkflowLoaderServiceProvider extends PackageServiceProvider
1010{
1111 public function configurePackage (Package $ package ): void
1212 {
13- /*
14- * This class is a Package Service Provider
15- *
16- * More info: https://github.com/spatie/laravel-package-tools
17- */
1813 $ package
1914 ->name ('laravel-workflow-loader ' )
2015 ->hasConfigFile ('workflow_loader ' )
@@ -30,16 +25,40 @@ public function configurePackage(Package $package): void
3025
3126 public function packageRegistered ()
3227 {
33- $ this ->app ->when (\Soap \WorkflowLoader \DatabaseLoader::class)
34- ->needs ('$config ' )
35- ->give ($ this ->app ->make ('config ' )->get ('workflow_loader.loaders.database ' ));
28+ // Register DatabaseLoader with safe config retrieval
29+ $ this ->app ->singleton (DatabaseLoader::class, function ($ app ) {
30+ $ config = $ app ['config ' ]->get ('workflow_loader.loaders.database ' , []);
31+
32+ // Provide default config if not found
33+ if (empty ($ config ) || !isset ($ config ['tableNames ' ])) {
34+ $ config = [
35+ 'tableNames ' => [
36+ 'workflows ' => 'workflows ' ,
37+ 'workflow_states ' => 'workflow_states ' ,
38+ 'workflow_transitions ' => 'workflow_transitions ' ,
39+ 'workflow_state_transitions ' => 'workflow_state_transitions ' ,
40+ ],
41+ ];
42+ }
43+
44+ return new DatabaseLoader (
45+ $ config ,
46+ $ app ->make (Repositories \WorkflowRepository::class)
47+ );
48+ });
3649
37- $ this ->app ->when (\Soap \WorkflowLoader \WorkflowLoaderRegistry::class)
38- ->needs ('$loaders ' )
39- ->give ($ this ->app ->make ('config ' )->get ('workflow_loader.loaders ' ));
50+ // Register WorkflowLoaderRegistry
51+ $ this ->app ->singleton (WorkflowLoaderRegistry::class, function ($ app ) {
52+ $ loaders = $ app ['config ' ]->get ('workflow_loader.loaders ' , []);
53+ return new WorkflowLoaderRegistry ($ loaders );
54+ });
4055
41- $ this ->app ->bind (\Soap \WorkflowLoader \Contracts \WorkflowDatabaseLoader::class, \Soap \WorkflowLoader \DatabaseLoader::class);
56+ // Bind contracts
57+ $ this ->app ->bind (
58+ Contracts \WorkflowDatabaseLoader::class,
59+ DatabaseLoader::class
60+ );
4261
43- $ this ->app ->singleton ('workflowLoaderRegistry ' , \ Soap \ WorkflowLoader \ WorkflowLoaderRegistry::class);
62+ $ this ->app ->singleton ('workflowLoaderRegistry ' , WorkflowLoaderRegistry::class);
4463 }
4564}
0 commit comments