-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServiceProvider.php
109 lines (92 loc) · 3.52 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* Playground
*/
declare(strict_types=1);
namespace Playground\Matrix;
use Illuminate\Foundation\Console\AboutCommand;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider;
/**
* \Playground\Matrix\ServiceProvider
*/
class ServiceProvider extends AuthServiceProvider
{
public const VERSION = '73.0.0';
public string $package = 'playground-matrix';
/**
* Bootstrap any package services.
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
/**
* @var array<string, mixed> $config
*/
$config = config($this->package);
if (! empty($config['load']) && is_array($config['load'])) {
if ($this->app->runningInConsole()) {
// Publish configuration
$this->publishes([
sprintf('%1$s/config/%2$s.php', dirname(__DIR__), $this->package) => config_path(sprintf('%1$s.php', $this->package)),
], 'playground-config');
// Publish migrations
$this->publishMigrations();
// Load migrations
if (! empty($config['load']['migrations'])) {
$this->loadMigrationsFrom(dirname(__DIR__).'/database/migrations');
}
}
}
if (! empty($config['about'])) {
$this->about();
}
}
/**
* Register any application services.
*/
public function register(): void
{
$this->mergeConfigFrom(
dirname(__DIR__).'/config/playground-matrix.php',
$this->package
);
}
public function publishMigrations(): void
{
$migrations = [];
foreach ([
'2020_01_02_100001_create_matrix_backlogs_table.php',
'2020_01_02_100001_create_matrix_boards_table.php',
'2020_01_02_100001_create_matrix_epics_table.php',
'2020_01_02_100001_create_matrix_flows_table.php',
'2020_01_02_100001_create_matrix_matrices_table.php',
'2020_01_02_100001_create_matrix_milestones_table.php',
'2020_01_02_100001_create_matrix_notes_table.php',
'2020_01_02_100001_create_matrix_projects_table.php',
'2020_01_02_100001_create_matrix_releases_table.php',
'2020_01_02_100001_create_matrix_roadmaps_table.php',
'2020_01_02_100001_create_matrix_sources_table.php',
'2020_01_02_100001_create_matrix_sprints_table.php',
'2020_01_02_100001_create_matrix_tags_table.php',
'2020_01_02_100001_create_matrix_teams_table.php',
'2020_01_02_100001_create_matrix_tickets_table.php',
'2020_01_02_100001_create_matrix_versions_table.php',
] as $file) {
$migrations[dirname(__DIR__).'/database/migrations/'.$file] = database_path('migrations/'.$file);
}
$this->publishes($migrations, 'playground-migrations');
}
public function about(): void
{
$config = config($this->package);
$config = is_array($config) ? $config : [];
$load = ! empty($config['load']) && is_array($config['load']) ? $config['load'] : [];
AboutCommand::add('Playground: Matrix', fn () => [
'<fg=yellow;options=bold>Load</> Migrations' => ! empty($load['migrations']) ? '<fg=green;options=bold>ENABLED</>' : '<fg=yellow;options=bold>DISABLED</>',
'Package' => $this->package,
'Version' => ServiceProvider::VERSION,
]);
}
}