1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Thinktomorrow\Chief\App\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Console\Scheduling\Schedule; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
use Thinktomorrow\Chief\Admin\Authorization\Console\GeneratePermissionCommand; |
8
|
|
|
use Thinktomorrow\Chief\Admin\Authorization\Console\GenerateRoleCommand; |
9
|
|
|
use Thinktomorrow\Chief\Admin\Setup\CreateFragmentCommand; |
10
|
|
|
use Thinktomorrow\Chief\Admin\Setup\CreatePageCommand; |
11
|
|
|
use Thinktomorrow\Chief\Admin\Setup\CreatePageMigrationCommand; |
12
|
|
|
use Thinktomorrow\Chief\Admin\Setup\CreateViewCommand; |
13
|
|
|
use Thinktomorrow\Chief\Admin\Setup\FileManipulation; |
14
|
|
|
use Thinktomorrow\Chief\Admin\Setup\SetupConfig; |
15
|
|
|
use Thinktomorrow\Chief\App\Console\CreateAdmin; |
16
|
|
|
use Thinktomorrow\Chief\App\Console\CreateDeveloper; |
17
|
|
|
use Thinktomorrow\Chief\App\Console\ImportRedirects; |
18
|
|
|
use Thinktomorrow\Chief\App\Console\ProjectMenuCommand; |
19
|
|
|
use Thinktomorrow\Chief\App\Console\RefreshDatabase; |
20
|
|
|
use Thinktomorrow\Chief\App\Console\Seed; |
21
|
|
|
use Thinktomorrow\Chief\App\Console\TranslationsExportCommand; |
22
|
|
|
|
23
|
|
|
class ConsoleServiceProvider extends ServiceProvider |
24
|
|
|
{ |
25
|
|
|
public function boot(): void |
26
|
|
|
{ |
27
|
|
|
$this->loadMigrationsFrom(__DIR__.'/../../database/migrations'); |
28
|
|
|
$this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'chief'); |
29
|
|
|
|
30
|
|
|
$this->publishes([ |
31
|
|
|
__DIR__.'/../../config/chief.php' => config_path('chief.php'), |
32
|
|
|
__DIR__.'/../../config/chief-settings.php' => config_path('chief-settings.php'), |
33
|
|
|
], 'chief-config'); |
34
|
|
|
|
35
|
|
|
$this->publishes([ |
36
|
|
|
__DIR__.'/../../public/chief-assets' => public_path('/chief-assets'), |
37
|
|
|
], 'chief-assets'); |
38
|
|
|
|
39
|
|
|
$this->commands([ |
40
|
|
|
// Local development |
41
|
|
|
'command.chief:refresh', |
42
|
|
|
'command.chief:seed', |
43
|
|
|
|
44
|
|
|
// Project setup tools |
45
|
|
|
'command.chief:permission', |
46
|
|
|
'command.chief:role', |
47
|
|
|
|
48
|
|
|
'command.chief:admin', |
49
|
|
|
'command.chief:developer', |
50
|
|
|
'command.chief:page', |
51
|
|
|
'command.chief:page-migration', |
52
|
|
|
'command.chief:fragment', |
53
|
|
|
'command.chief:view', |
54
|
|
|
'command.chief:project-menu', |
55
|
|
|
'command.chief:import-redirects', |
56
|
|
|
'command.chief:translations-export', |
57
|
|
|
]); |
58
|
|
|
|
59
|
|
|
// Bind our commands to the container |
60
|
|
|
$this->app->bind('command.chief:refresh', RefreshDatabase::class); |
61
|
|
|
$this->app->bind('command.chief:seed', Seed::class); |
62
|
|
|
$this->app->bind('command.chief:permission', GeneratePermissionCommand::class); |
63
|
|
|
$this->app->bind('command.chief:role', GenerateRoleCommand::class); |
64
|
|
|
|
65
|
|
|
$this->app->bind('command.chief:page', CreatePageCommand::class); |
66
|
|
|
$this->app->bind('command.chief:page-migration', CreatePageMigrationCommand::class); |
67
|
|
|
$this->app->bind('command.chief:view', CreateViewCommand::class); |
68
|
|
|
$this->app->bind('command.chief:fragment', CreateFragmentCommand::class); |
69
|
|
|
$this->app->bind('command.chief:admin', CreateAdmin::class); |
70
|
|
|
$this->app->bind('command.chief:developer', CreateDeveloper::class); |
71
|
|
|
$this->app->bind('command.chief:project-menu', ProjectMenuCommand::class); |
72
|
|
|
$this->app->bind('command.chief:import-redirects', ImportRedirects::class); |
73
|
|
|
$this->app->bind('command.chief:translations-export', TranslationsExportCommand::class); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function register() |
77
|
|
|
{ |
78
|
|
|
$this->callAfterResolving(Schedule::class, function (Schedule $schedule) { |
79
|
|
|
$schedule->command('chief:sitemap')->dailyAt('01:00'); |
80
|
|
|
$schedule->command('chief:image-sitemap')->weekly(); |
81
|
|
|
}); |
82
|
|
|
|
83
|
|
|
// Setup commands |
84
|
|
|
$this->app->bind(CreatePageCommand::class, function ($app) { |
85
|
|
|
return new CreatePageCommand($app->make(FileManipulation::class), new SetupConfig(config('chief.setup', []))); |
86
|
|
|
}); |
87
|
|
|
|
88
|
|
|
$this->app->bind(CreateFragmentCommand::class, function ($app) { |
89
|
|
|
return new CreateFragmentCommand($app->make(FileManipulation::class), new SetupConfig(config('chief.setup', []))); |
90
|
|
|
}); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|