1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Providers; |
4
|
|
|
|
5
|
|
|
use App\Porter; |
6
|
|
|
use App\PorterLibrary; |
7
|
|
|
use App\Support\Console\Cli; |
8
|
|
|
use App\Support\Console\ConsoleWriter; |
9
|
|
|
use App\Support\Console\ServerBag; |
10
|
|
|
use App\Support\Contracts\Cli as CliContract; |
11
|
|
|
use App\Support\Contracts\ImageSetRepository as ImageSetRepositoryContract; |
12
|
|
|
use App\Support\FilePublisher; |
13
|
|
|
use App\Support\Images\ImageSetRepository; |
14
|
|
|
use App\Support\Images\Organiser\Organiser; |
15
|
|
|
use App\Support\Mechanics\ChooseMechanic; |
16
|
|
|
use App\Support\Mechanics\Mechanic; |
17
|
|
|
use App\Support\Ssl\CertificateBuilder; |
18
|
|
|
use Illuminate\Filesystem\Filesystem; |
19
|
|
|
use Illuminate\Support\ServiceProvider; |
20
|
|
|
use LaravelZero\Framework\Application; |
21
|
|
|
|
22
|
|
|
class AppServiceProvider extends ServiceProvider |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* Bootstrap any application services. |
26
|
|
|
*/ |
27
|
172 |
|
public function boot(): void |
28
|
|
|
{ |
29
|
172 |
|
view()->getFinder()->prependLocation(app(PorterLibrary::class)->viewsPath()); |
30
|
|
|
|
31
|
172 |
|
$this->app[ImageSetRepositoryContract::class]->registerViewNamespaces($this->app); |
32
|
172 |
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Register any application services. |
36
|
|
|
*/ |
37
|
172 |
|
public function register(): void |
38
|
|
|
{ |
39
|
|
|
$this->app->singleton(CertificateBuilder::class, function () { |
40
|
8 |
|
return new CertificateBuilder( |
41
|
8 |
|
app(CliContract::class), |
42
|
8 |
|
app(Filesystem::class), |
43
|
8 |
|
app(Mechanic::class), |
44
|
8 |
|
app(PorterLibrary::class)->sslPath() |
45
|
|
|
); |
46
|
172 |
|
}); |
47
|
|
|
|
48
|
172 |
|
$this->app->bind(ConsoleWriter::class); |
49
|
|
|
|
50
|
172 |
|
$this->app->bind(CliContract::class, Cli::class); |
51
|
|
|
$this->app->bind(Cli::class, function () { |
52
|
172 |
|
return (new Cli())->setTimeout(config('porter.process_timeout')); |
53
|
172 |
|
}); |
54
|
|
|
|
55
|
|
|
$this->app->bind(ImageSetRepositoryContract::class, function () { |
56
|
172 |
|
return new ImageSetRepository([ |
57
|
172 |
|
resource_path('image_sets'), |
58
|
172 |
|
app(PorterLibrary::class)->dockerImagesPath(), |
59
|
|
|
]); |
60
|
172 |
|
}); |
61
|
|
|
|
62
|
|
|
$this->app->bind(Organiser::class, function () { |
63
|
|
|
return new Organiser( |
64
|
|
|
app(Porter::class)->getDockerImageSet(), |
65
|
|
|
app(CliContract::class), |
66
|
|
|
app(FileSystem::class) |
67
|
|
|
); |
68
|
172 |
|
}); |
69
|
|
|
|
70
|
172 |
|
$this->app->singleton(Porter::class); |
71
|
|
|
|
72
|
|
|
$this->app->singleton(PorterLibrary::class, function (Application $app) { |
73
|
172 |
|
return new PorterLibrary($app->make(FilePublisher::class), $app->make(Mechanic::class), config('porter.library_path')); |
74
|
172 |
|
}); |
75
|
|
|
|
76
|
172 |
|
$this->app->singleton(ServerBag::class); |
77
|
|
|
|
78
|
|
|
$this->app->bind(Mechanic::class, function () { |
79
|
172 |
|
return ChooseMechanic::forOS(); |
80
|
172 |
|
}); |
81
|
172 |
|
} |
82
|
|
|
} |
83
|
|
|
|