|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SaasReady; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Foundation\Console\AboutCommand; |
|
|
|
|
|
|
6
|
|
|
use Illuminate\Support\Facades\Event; |
|
|
|
|
|
|
7
|
|
|
use Illuminate\Support\Facades\Route; |
|
|
|
|
|
|
8
|
|
|
use Illuminate\Support\ServiceProvider; |
|
|
|
|
|
|
9
|
|
|
use SaasReady\Commands\ActivateEntityCommand; |
|
10
|
|
|
use SaasReady\Commands\DeactivateEntityCommand; |
|
11
|
|
|
use SaasReady\Commands\RenderTranslationsCommand; |
|
12
|
|
|
use SaasReady\Contracts\EventSourcingContract; |
|
13
|
|
|
use SaasReady\Contracts\TranslationRepositoryContract; |
|
14
|
|
|
use SaasReady\Listeners\EventSourcingListener; |
|
15
|
|
|
use SaasReady\Models\Country; |
|
|
|
|
|
|
16
|
|
|
use SaasReady\Models\Currency; |
|
|
|
|
|
|
17
|
|
|
use SaasReady\Models\DynamicSetting; |
|
|
|
|
|
|
18
|
|
|
use SaasReady\Models\Event as EventModel; |
|
19
|
|
|
use SaasReady\Models\ReleaseNote; |
|
20
|
|
|
use SaasReady\Models\Translation; |
|
|
|
|
|
|
21
|
|
|
use SaasReady\Services\TranslationRepositories\CacheTranslationRepository; |
|
|
|
|
|
|
22
|
|
|
use SaasReady\Services\TranslationRepositories\DatabaseTranslationRepository; |
|
23
|
|
|
|
|
24
|
|
|
class SaasServiceProvider extends ServiceProvider |
|
25
|
|
|
{ |
|
26
|
|
|
public function boot(): void |
|
27
|
|
|
{ |
|
28
|
|
|
AboutCommand::add('ShipSaaS/Ready', fn () => ['Version' => '1.0.0']); |
|
29
|
|
|
|
|
30
|
|
|
$this->mergeConfigFrom(__DIR__ . '/Configs/saas-ready.php', 'saas-ready'); |
|
31
|
|
|
|
|
32
|
|
|
$this->publishes([ |
|
33
|
|
|
__DIR__ . '/Configs/saas-ready.php' => config_path('saas-ready.php'), |
|
|
|
|
|
|
34
|
|
|
], 'saas-ready'); |
|
35
|
|
|
|
|
36
|
|
|
$this->loadMigrationsFrom(__DIR__ . '/Database/Migrations'); |
|
37
|
|
|
$this->loadRoutesFrom(__DIR__ . '/Routes/saas-ready-routes.php'); |
|
38
|
|
|
$this->loadArtisanCommands(); |
|
39
|
|
|
|
|
40
|
|
|
Event::listen(EventSourcingContract::class, function (EventSourcingContract $event) { |
|
41
|
|
|
if (!config('saas-ready.event-sourcing.should-queue')) { |
|
|
|
|
|
|
42
|
|
|
EventSourcingListener::dispatchSync($event); |
|
43
|
|
|
|
|
44
|
|
|
return; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
EventSourcingListener::dispatch($event) |
|
48
|
|
|
->onQueue(config('saas-ready.event-sourcing.queue-name')) |
|
49
|
|
|
->onConnection(config('saas-ready.event-sourcing.queue-connection')); |
|
50
|
|
|
}); |
|
51
|
|
|
|
|
52
|
|
|
Route::model('currency', Currency::class); |
|
53
|
|
|
Route::model('country', Country::class); |
|
54
|
|
|
Route::model('event', EventModel::class); |
|
55
|
|
|
Route::model('translation', Translation::class); |
|
56
|
|
|
Route::model('dynamicSetting', DynamicSetting::class); |
|
57
|
|
|
Route::model('releaseNote', ReleaseNote::class); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function register(): void |
|
61
|
|
|
{ |
|
62
|
|
|
$this->app->singleton(DatabaseTranslationRepository::class); |
|
63
|
|
|
$this->app->singleton(CacheTranslationRepository::class); |
|
64
|
|
|
|
|
65
|
|
|
$this->app->bind(TranslationRepositoryContract::class, function () { |
|
66
|
|
|
if (config('saas-ready.translation.should-cache')) { |
|
|
|
|
|
|
67
|
|
|
return $this->app->make(CacheTranslationRepository::class); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
return $this->app->make(DatabaseTranslationRepository::class); |
|
71
|
|
|
}); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
private function loadArtisanCommands(): void |
|
75
|
|
|
{ |
|
76
|
|
|
if (!$this->app->runningInConsole()) { |
|
77
|
|
|
return; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
$this->commands([ |
|
81
|
|
|
ActivateEntityCommand::class, |
|
82
|
|
|
DeactivateEntityCommand::class, |
|
83
|
|
|
RenderTranslationsCommand::class, |
|
84
|
|
|
]); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths