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
|
|
|
|
21
|
|
|
class AppServiceProvider extends ServiceProvider |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Bootstrap any application services. |
25
|
|
|
*/ |
26
|
94 |
|
public function boot(): void |
27
|
|
|
{ |
28
|
94 |
|
view()->getFinder()->prependLocation(app(PorterLibrary::class)->viewsPath()); |
29
|
|
|
|
30
|
94 |
|
$this->app[ImageSetRepositoryContract::class]->registerViewNamespaces($this->app); |
31
|
94 |
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Register any application services. |
35
|
|
|
*/ |
36
|
94 |
|
public function register(): void |
37
|
|
|
{ |
38
|
|
|
$this->app->singleton(CertificateBuilder::class, function () { |
39
|
5 |
|
return new CertificateBuilder( |
40
|
5 |
|
app(CliContract::class), |
41
|
5 |
|
app(Filesystem::class), |
42
|
5 |
|
app(Mechanic::class), |
43
|
5 |
|
app(PorterLibrary::class)->sslPath() |
44
|
|
|
); |
45
|
94 |
|
}); |
46
|
|
|
|
47
|
94 |
|
$this->app->bind(ConsoleWriter::class); |
48
|
|
|
|
49
|
94 |
|
$this->app->bind(CliContract::class, Cli::class); |
50
|
|
|
|
51
|
|
|
$this->app->bind(ImageSetRepositoryContract::class, function () { |
52
|
94 |
|
return new ImageSetRepository([ |
53
|
94 |
|
resource_path('image_sets'), |
54
|
94 |
|
app(PorterLibrary::class)->dockerImagesPath(), |
55
|
|
|
]); |
56
|
94 |
|
}); |
57
|
|
|
|
58
|
|
|
$this->app->bind(Organiser::class, function () { |
59
|
|
|
return new Organiser( |
60
|
|
|
app(Porter::class)->getDockerImageSet(), |
61
|
|
|
app(CliContract::class), |
62
|
|
|
app(FileSystem::class) |
63
|
|
|
); |
64
|
94 |
|
}); |
65
|
|
|
|
66
|
94 |
|
$this->app->singleton(Porter::class); |
67
|
|
|
|
68
|
|
|
$this->app->singleton(PorterLibrary::class, function () { |
69
|
94 |
|
return new PorterLibrary(app(FilePublisher::class), config('porter.library_path')); |
70
|
94 |
|
}); |
71
|
|
|
|
72
|
94 |
|
$this->app->singleton(ServerBag::class); |
73
|
|
|
|
74
|
|
|
$this->app->bind(Mechanic::class, function () { |
75
|
5 |
|
return ChooseMechanic::forOS(); |
76
|
94 |
|
}); |
77
|
94 |
|
} |
78
|
|
|
} |
79
|
|
|
|