-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathServiceProvider.php
89 lines (73 loc) · 2.38 KB
/
ServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
declare(strict_types=1);
namespace DragonCode\LaravelDeployOperations;
use DragonCode\LaravelDeployOperations\Concerns\HasAbout;
use DragonCode\LaravelDeployOperations\Data\Config\ConfigData;
use DragonCode\LaravelDeployOperations\Listeners\MigrationEndedListener;
use Illuminate\Database\Events\MigrationEnded;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use function config;
class ServiceProvider extends BaseServiceProvider
{
use HasAbout;
public function boot(): void
{
$this->registerEvents();
$this->bootConfig();
if ($this->app->runningInConsole()) {
$this->publishConfig();
$this->publishStub();
$this->registerAbout();
$this->registerCommands();
$this->registerMigrations();
}
}
public function register(): void
{
$this->registerConfig();
}
protected function registerCommands(): void
{
$this->commands([
Console\OperationsCommand::class,
Console\FreshCommand::class,
Console\InstallCommand::class,
Console\MakeCommand::class,
Console\RollbackCommand::class,
Console\StatusCommand::class,
]);
}
protected function registerEvents(): void
{
Event::listen(MigrationEnded::class, MigrationEndedListener::class);
}
protected function registerMigrations(): void
{
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
}
protected function publishConfig(): void
{
$this->publishes([
__DIR__ . '/../config/deploy-operations.php' => $this->app->configPath('deploy-operations.php'),
], ['config', 'deploy-operations']);
}
protected function publishStub(): void
{
$this->publishes([
__DIR__ . '/../resources/stubs/deploy-operation.stub' => $this->app->basePath(
'stubs/deploy-operation.stub'
),
], ['stubs', 'deploy-operations']);
}
protected function registerConfig(): void
{
$this->mergeConfigFrom(__DIR__ . '/../config/deploy-operations.php', 'deploy-operations');
}
protected function bootConfig(): void
{
$this->app->bind(ConfigData::class, static fn () => ConfigData::from(
config('deploy-operations')
));
}
}