1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Cortex\Console\Providers; |
6
|
|
|
|
7
|
|
|
use Cortex\Console\Services\Terminal; |
8
|
|
|
use Illuminate\Support\ServiceProvider; |
9
|
|
|
use Rinvex\Support\Traits\ConsoleTools; |
10
|
|
|
use Cortex\Console\Console\Commands\Find; |
11
|
|
|
use Cortex\Console\Console\Commands\Tail; |
12
|
|
|
use Cortex\Console\Console\Commands\Mysql; |
13
|
|
|
use Cortex\Console\Console\Commands\Artisan; |
14
|
|
|
use Cortex\Console\Console\Commands\Composer; |
15
|
|
|
use Cortex\Console\Console\Commands\SeedCommand; |
16
|
|
|
use Cortex\Console\Console\Commands\ArtisanTinker; |
17
|
|
|
use Cortex\Console\Console\Commands\InstallCommand; |
18
|
|
|
use Cortex\Console\Console\Commands\PublishCommand; |
19
|
|
|
|
20
|
|
|
class ConsoleServiceProvider extends ServiceProvider |
21
|
|
|
{ |
22
|
|
|
use ConsoleTools; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* The commands to be registered. |
26
|
|
|
* |
27
|
|
|
* @var array |
28
|
|
|
*/ |
29
|
|
|
protected $commands = [ |
30
|
|
|
SeedCommand::class => 'command.cortex.console.seed', |
31
|
|
|
PublishCommand::class => 'command.cortex.console.publish', |
32
|
|
|
InstallCommand::class => 'command.cortex.console.install', |
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Register any application services. |
37
|
|
|
* |
38
|
|
|
* This service provider is a great spot to register your various container |
39
|
|
|
* bindings with the application. As you can see, we are registering our |
40
|
|
|
* "Registrar" implementation here. You can add your own bindings too! |
41
|
|
|
* |
42
|
|
|
* @return void |
43
|
|
|
*/ |
44
|
|
|
public function register(): void |
45
|
|
|
{ |
46
|
|
|
// Register console commands |
47
|
|
|
! $this->app->runningInConsole() || $this->registerCommands(); |
48
|
|
|
|
49
|
|
|
$this->app->singleton(Terminal::class, function ($app) { |
50
|
|
|
$_SERVER['PHP_SELF'] = 'artisan'; // Fix (index.php => artisan) |
51
|
|
|
$artisan = new Terminal($app, $app['events'], $app->version()); |
52
|
|
|
|
53
|
|
|
return $artisan; |
54
|
|
|
}); |
55
|
|
|
|
56
|
|
|
if (! $this->app->runningInConsole()) { |
57
|
|
|
$commands = [ |
58
|
|
|
Find::class, |
59
|
|
|
Artisan::class, |
60
|
|
|
ArtisanTinker::class, |
61
|
|
|
Composer::class, |
62
|
|
|
Mysql::class, |
63
|
|
|
Tail::class, |
64
|
|
|
]; |
65
|
|
|
|
66
|
|
|
Terminal::starting(function ($artisan) use ($commands) { |
67
|
|
|
$artisan->resolveCommands($commands); |
68
|
|
|
}); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Bootstrap any application services. |
74
|
|
|
* |
75
|
|
|
* @return void |
76
|
|
|
*/ |
77
|
|
|
public function boot(): void |
78
|
|
|
{ |
79
|
|
|
// Load resources |
80
|
|
|
$this->loadRoutesFrom(__DIR__.'/../../routes/web/adminarea.php'); |
81
|
|
|
$this->loadViewsFrom(__DIR__.'/../../resources/views', 'cortex/console'); |
82
|
|
|
$this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'cortex/console'); |
83
|
|
|
$this->app->runningInConsole() || $this->app->afterResolving('blade.compiler', function () { |
84
|
|
|
$accessarea = $this->app['request']->route('accessarea'); |
85
|
|
|
! file_exists($menus = __DIR__."/../../routes/menus/{$accessarea}.php") || require $menus; |
86
|
|
|
! file_exists($breadcrumbs = __DIR__."/../../routes/breadcrumbs/{$accessarea}.php") || require $breadcrumbs; |
87
|
|
|
}); |
88
|
|
|
|
89
|
|
|
// Publish Resources |
90
|
|
|
! $this->app->runningInConsole() || $this->publishesLang('cortex/console', true); |
91
|
|
|
! $this->app->runningInConsole() || $this->publishesViews('cortex/console', true); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|