1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Providers; |
4
|
|
|
|
5
|
|
|
use App\Src\UseCases\Domain\Ports\ContextRepository; |
6
|
|
|
use App\Src\UseCases\Domain\Ports\IdentityProvider; |
7
|
|
|
use App\Src\UseCases\Domain\Ports\InteractionRepository; |
8
|
|
|
use App\Src\UseCases\Domain\Ports\InvitationRepository; |
9
|
|
|
use App\Src\UseCases\Domain\Ports\CharacteristicsRepository; |
10
|
|
|
use App\Src\UseCases\Domain\Ports\OrganizationRepository; |
11
|
|
|
use App\Src\UseCases\Domain\Ports\PageRepository; |
12
|
|
|
use App\Src\UseCases\Domain\Ports\UserRepository; |
13
|
|
|
use App\Src\UseCases\Domain\Ports\UserRoleRepository; |
14
|
|
|
use App\Src\UseCases\Domain\Shared\Gateway\AuthGateway; |
15
|
|
|
use App\Src\UseCases\Domain\Shared\Gateway\FileStorage; |
16
|
|
|
use App\Src\UseCases\Domain\Shared\Gateway\PictureHandler; |
17
|
|
|
use App\Src\UseCases\Domain\Shared\Gateway\SocialiteGateway; |
18
|
|
|
use App\Src\UseCases\Domain\Shared\Provider\IdentityProviderImpl; |
19
|
|
|
use App\Src\UseCases\Domain\System\GetDepartmentFromPostalCode; |
20
|
|
|
use App\Src\UseCases\Domain\System\GetDepartmentFromPostalCodeImpl; |
21
|
|
|
use App\Src\UseCases\Infra\Gateway\FsFileStorage; |
22
|
|
|
use App\Src\UseCases\Infra\Gateway\SessionAuthGateway; |
23
|
|
|
use App\Src\UseCases\Infra\Gateway\SocialiteGatewayImpl; |
24
|
|
|
use App\Src\UseCases\Infra\Gateway\StoragePictureHandler; |
25
|
|
|
use App\Src\UseCases\Infra\Sql\ContextRepositorySql; |
26
|
|
|
use App\Src\UseCases\Infra\Sql\InteractionPageRepositorySql; |
27
|
|
|
use App\Src\UseCases\Infra\Sql\InvitationRepositorySql; |
28
|
|
|
use App\Src\UseCases\Infra\Sql\CharacteristicsRepositorySql; |
29
|
|
|
use App\Src\UseCases\Infra\Sql\PageRepositorySql; |
30
|
|
|
use App\Src\UseCases\Infra\Sql\SqlOrganizationRepository; |
31
|
|
|
use App\Src\UseCases\Infra\Sql\UserRepositorySql; |
32
|
|
|
use App\Src\UseCases\Infra\Sql\UserRoleRepositorySql; |
33
|
|
|
use App\Src\Utils\Hash\HashGen; |
34
|
|
|
use App\Src\Utils\Hash\HashGenReal; |
35
|
|
|
use App\Src\Utils\Hash\InMemoryHashGen; |
36
|
|
|
use Illuminate\Support\Facades\Schema; |
37
|
|
|
use Illuminate\Support\Facades\URL; |
38
|
|
|
use Illuminate\Support\ServiceProvider; |
39
|
|
|
use Tests\Adapters\Gateway\InMemoryAuthGateway; |
40
|
|
|
use Tests\Adapters\Gateway\InMemoryFileStorage; |
41
|
|
|
use Tests\Adapters\Gateway\InMemoryGetDepartmentsFromPostalCode; |
42
|
|
|
use Tests\Adapters\Gateway\InMemoryPictureHandler; |
43
|
|
|
use Tests\Adapters\Gateway\InMemorySocialiteGateway; |
44
|
|
|
use Tests\Adapters\Repositories\InMemoryCharacteristicRepository; |
45
|
|
|
use Tests\Adapters\Repositories\InMemoryContextRepository; |
46
|
|
|
use Tests\Adapters\Repositories\InMemoryInteractionRepository; |
47
|
|
|
use Tests\Adapters\Repositories\InMemoryInvitationRepository; |
48
|
|
|
use Tests\Adapters\Repositories\InMemoryOrganizationRepository; |
49
|
|
|
use Tests\Adapters\Repositories\InMemoryPageRepository; |
50
|
|
|
use Tests\Adapters\Repositories\InMemoryUserRepository; |
51
|
|
|
use Tests\Adapters\Repositories\InMemoryUserRoleRepository; |
52
|
|
|
|
53
|
|
|
class AppServiceProvider extends ServiceProvider |
54
|
|
|
{ |
55
|
|
|
public function register() |
56
|
|
|
{ |
57
|
|
|
$this->registerHelpers(); |
58
|
|
|
|
59
|
|
|
if(config('app.env') === 'testing'){ |
60
|
|
|
$this->tuBinding(); |
61
|
|
|
} |
62
|
|
|
if(config('app.env') === 'testing-ti'){ |
63
|
|
|
$this->tiBinding(); |
64
|
|
|
} |
65
|
|
|
if(config('app.env') === 'local' || config('app.env') === 'production'){ |
66
|
|
|
$this->prodBinding(); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function boot() |
71
|
|
|
{ |
72
|
|
|
if(config('app.env') !== 'testing' && config('app.env') !== 'testing-ti') { |
73
|
|
|
Schema::defaultStringLength(191); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
if(config('app.env') === 'local' || config('app.env') === 'production'){ |
77
|
|
|
URL::forceScheme('https'); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
private function registerHelpers(): void |
82
|
|
|
{ |
83
|
|
|
foreach (glob(app_path() . '/Src/Utils/Helpers/*.php') as $filename) { |
84
|
|
|
require_once($filename); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
private function prodBinding(): void |
89
|
|
|
{ |
90
|
|
|
$this->app->singleton(IdentityProvider::class, IdentityProviderImpl::class); |
91
|
|
|
$this->app->singleton(OrganizationRepository::class, SqlOrganizationRepository::class); |
92
|
|
|
$this->app->singleton(InvitationRepository::class, InvitationRepositorySql::class); |
93
|
|
|
$this->app->singleton(PictureHandler::class, StoragePictureHandler::class); |
94
|
|
|
$this->app->singleton(UserRepository::class, UserRepositorySql::class); |
95
|
|
|
$this->app->singleton(AuthGateway::class, SessionAuthGateway::class); |
96
|
|
|
$this->app->singleton(FileStorage::class, FsFileStorage::class); |
97
|
|
|
$this->app->singleton(SocialiteGateway::class, SocialiteGatewayImpl::class); |
98
|
|
|
$this->app->singleton(HashGen::class, HashGenReal::class); |
99
|
|
|
$this->app->singleton(UserRoleRepository::class, UserRoleRepositorySql::class); |
100
|
|
|
$this->app->singleton(ContextRepository::class, ContextRepositorySql::class); |
101
|
|
|
$this->app->singleton(CharacteristicsRepository::class, CharacteristicsRepositorySql::class); |
102
|
|
|
$this->app->singleton(PageRepository::class, PageRepositorySql::class); |
103
|
|
|
$this->app->singleton(InteractionRepository::class, InteractionPageRepositorySql::class); |
104
|
|
|
$this->app->singleton(GetDepartmentFromPostalCode::class, GetDepartmentFromPostalCodeImpl::class); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
private function tuBinding(): void |
108
|
|
|
{ |
109
|
|
|
$this->app->singleton(IdentityProvider::class, IdentityProviderImpl::class); |
110
|
|
|
$this->app->singleton(OrganizationRepository::class, InMemoryOrganizationRepository::class); |
111
|
|
|
$this->app->singleton(PictureHandler::class, InMemoryPictureHandler::class); |
112
|
|
|
$this->app->singleton(UserRepository::class, InMemoryUserRepository::class); |
113
|
|
|
$this->app->singleton(FileStorage::class, InMemoryFileStorage::class); |
114
|
|
|
$this->app->singleton(AuthGateway::class, InMemoryAuthGateway::class); |
115
|
|
|
$this->app->singleton(SocialiteGateway::class, InMemorySocialiteGateway::class); |
116
|
|
|
$this->app->singleton(HashGen::class, InMemoryHashGen::class); |
117
|
|
|
$this->app->singleton(InvitationRepository::class, InMemoryInvitationRepository::class); |
118
|
|
|
$this->app->singleton(UserRoleRepository::class, InMemoryUserRoleRepository::class); |
119
|
|
|
$this->app->singleton(ContextRepository::class, InMemoryContextRepository::class); |
120
|
|
|
$this->app->singleton(CharacteristicsRepository::class, InMemoryCharacteristicRepository::class); |
121
|
|
|
$this->app->singleton(PageRepository::class, InMemoryPageRepository::class); |
122
|
|
|
$this->app->singleton(InteractionRepository::class, InMemoryInteractionRepository::class); |
123
|
|
|
$this->app->singleton(GetDepartmentFromPostalCode::class, InMemoryGetDepartmentsFromPostalCode::class); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
private function tiBinding(): void |
127
|
|
|
{ |
128
|
|
|
$this->app->singleton(IdentityProvider::class, IdentityProviderImpl::class); |
129
|
|
|
$this->app->singleton(OrganizationRepository::class, SqlOrganizationRepository::class); |
130
|
|
|
$this->app->singleton(InvitationRepository::class, InvitationRepositorySql::class); |
131
|
|
|
$this->app->singleton(PictureHandler::class, InMemoryPictureHandler::class); |
132
|
|
|
$this->app->singleton(UserRepository::class, UserRepositorySql::class); |
133
|
|
|
$this->app->singleton(AuthGateway::class, InMemoryAuthGateway::class); |
134
|
|
|
$this->app->singleton(FileStorage::class, InMemoryFileStorage::class); |
135
|
|
|
$this->app->singleton(HashGen::class, InMemoryHashGen::class); |
136
|
|
|
$this->app->singleton(SocialiteGateway::class, InMemorySocialiteGateway::class); |
137
|
|
|
$this->app->singleton(ContextRepository::class, ContextRepositorySql::class); |
138
|
|
|
$this->app->singleton(CharacteristicsRepository::class, CharacteristicsRepositorySql::class); |
139
|
|
|
$this->app->singleton(PageRepository::class, PageRepositorySql::class); |
140
|
|
|
$this->app->singleton(InteractionRepository::class, InteractionPageRepositorySql::class); |
141
|
|
|
$this->app->singleton(GetDepartmentFromPostalCode::class, InMemoryGetDepartmentsFromPostalCode::class); |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|