|
3 | 3 | namespace SolutionForest\WorkflowEngine\Laravel\Providers;
|
4 | 4 |
|
5 | 5 | use Illuminate\Database\DatabaseManager;
|
| 6 | +use Illuminate\Support\ServiceProvider; |
6 | 7 | use SolutionForest\WorkflowEngine\Contracts\StorageAdapter;
|
7 | 8 | use SolutionForest\WorkflowEngine\Core\WorkflowEngine;
|
8 | 9 | use SolutionForest\WorkflowEngine\Laravel\Commands\LaravelWorkflowEngineCommand;
|
9 | 10 | use SolutionForest\WorkflowEngine\Laravel\Storage\DatabaseStorage;
|
10 |
| -use Spatie\LaravelPackageTools\Package; |
11 |
| -use Spatie\LaravelPackageTools\PackageServiceProvider; |
12 | 11 |
|
13 |
| -class WorkflowEngineServiceProvider extends PackageServiceProvider |
| 12 | +class WorkflowEngineServiceProvider extends ServiceProvider |
14 | 13 | {
|
15 |
| - public function configurePackage(Package $package): void |
16 |
| - { |
17 |
| - /* |
18 |
| - * This class is a Package Service Provider |
19 |
| - * |
20 |
| - * More info: https://github.com/spatie/laravel-package-tools |
21 |
| - */ |
22 |
| - $package |
23 |
| - ->name('workflow-engine') |
24 |
| - ->hasConfigFile() |
25 |
| - ->hasViews() |
26 |
| - ->hasMigration('create_workflow_instances_table') |
27 |
| - ->hasCommand(LaravelWorkflowEngineCommand::class); |
28 |
| - } |
29 |
| - |
30 | 14 | public function register(): void
|
31 | 15 | {
|
32 |
| - parent::register(); |
| 16 | + // Merge config |
| 17 | + $this->mergeConfigFrom( |
| 18 | + __DIR__.'/../../config/workflow-engine.php', |
| 19 | + 'workflow-engine' |
| 20 | + ); |
33 | 21 |
|
34 | 22 | // Register storage adapter
|
35 | 23 | $this->app->singleton(StorageAdapter::class, function ($app): StorageAdapter {
|
@@ -73,6 +61,32 @@ public function register(): void
|
73 | 61 |
|
74 | 62 | public function boot(): void
|
75 | 63 | {
|
76 |
| - parent::boot(); |
| 64 | + // Publish config file |
| 65 | + if ($this->app->runningInConsole()) { |
| 66 | + $this->publishes([ |
| 67 | + __DIR__.'/../../config/workflow-engine.php' => config_path('workflow-engine.php'), |
| 68 | + ], 'workflow-engine-config'); |
| 69 | + } |
| 70 | + |
| 71 | + // Publish migrations |
| 72 | + if ($this->app->runningInConsole()) { |
| 73 | + $this->publishes([ |
| 74 | + __DIR__.'/../../database/migrations/create_workflow_instances_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_workflow_instances_table.php'), |
| 75 | + ], 'workflow-engine-migrations'); |
| 76 | + } |
| 77 | + |
| 78 | + // Publish views |
| 79 | + if ($this->app->runningInConsole()) { |
| 80 | + $this->publishes([ |
| 81 | + __DIR__.'/../../resources/views' => resource_path('views/vendor/workflow-engine'), |
| 82 | + ], 'workflow-engine-views'); |
| 83 | + } |
| 84 | + |
| 85 | + // Register commands |
| 86 | + if ($this->app->runningInConsole()) { |
| 87 | + $this->commands([ |
| 88 | + LaravelWorkflowEngineCommand::class, |
| 89 | + ]); |
| 90 | + } |
77 | 91 | }
|
78 | 92 | }
|
0 commit comments