|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Omatech\Mage\Core; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Filesystem\Filesystem; |
|
6
|
|
|
use Illuminate\Support\ServiceProvider; |
|
7
|
|
|
use Omatech\Mage\Core\Domains\Permissions\Contracts\AllPermissionInterface; |
|
8
|
|
|
use Omatech\Mage\Core\Domains\Permissions\Contracts\AttachedPermissionInterface; |
|
9
|
|
|
use Omatech\Mage\Core\Domains\Permissions\Contracts\CreatePermissionInterface; |
|
10
|
|
|
use Omatech\Mage\Core\Domains\Permissions\Contracts\DeletePermissionInterface; |
|
11
|
|
|
use Omatech\Mage\Core\Domains\Permissions\Contracts\ExistsPermissionInterface; |
|
12
|
|
|
use Omatech\Mage\Core\Domains\Permissions\Contracts\FindPermissionInterface; |
|
13
|
|
|
use Omatech\Mage\Core\Domains\Permissions\Contracts\PermissionInterface; |
|
14
|
|
|
use Omatech\Mage\Core\Domains\Permissions\Contracts\UniquePermissionInterface; |
|
15
|
|
|
use Omatech\Mage\Core\Domains\Permissions\Contracts\UpdatePermissionInterface; |
|
16
|
|
|
use Omatech\Mage\Core\Domains\Permissions\Permission; |
|
17
|
|
|
use Omatech\Mage\Core\Domains\Roles\Contracts\AllRoleInterface; |
|
18
|
|
|
use Omatech\Mage\Core\Domains\Roles\Contracts\AttachedRoleInterface; |
|
19
|
|
|
use Omatech\Mage\Core\Domains\Roles\Contracts\CreateRoleInterface; |
|
20
|
|
|
use Omatech\Mage\Core\Domains\Roles\Contracts\DeleteRoleInterface; |
|
21
|
|
|
use Omatech\Mage\Core\Domains\Roles\Contracts\ExistsRoleInterface; |
|
22
|
|
|
use Omatech\Mage\Core\Domains\Roles\Contracts\FindRoleInterface; |
|
23
|
|
|
use Omatech\Mage\Core\Domains\Roles\Contracts\RoleInterface; |
|
24
|
|
|
use Omatech\Mage\Core\Domains\Roles\Contracts\UniqueRoleInterface; |
|
25
|
|
|
use Omatech\Mage\Core\Domains\Roles\Contracts\UpdateRoleInterface; |
|
26
|
|
|
use Omatech\Mage\Core\Domains\Roles\Role; |
|
27
|
|
|
use Omatech\Mage\Core\Domains\Translations\Contracts\AllTranslationInterface; |
|
28
|
|
|
use Omatech\Mage\Core\Domains\Translations\Contracts\CreateTranslationInterface; |
|
29
|
|
|
use Omatech\Mage\Core\Domains\Translations\Contracts\DeleteTranslationInterface; |
|
30
|
|
|
use Omatech\Mage\Core\Domains\Translations\Contracts\ExistsTranslationInterface; |
|
31
|
|
|
use Omatech\Mage\Core\Domains\Translations\Contracts\FindTranslationInterface; |
|
32
|
|
|
use Omatech\Mage\Core\Domains\Translations\Contracts\TranslationInterface; |
|
33
|
|
|
use Omatech\Mage\Core\Domains\Translations\Contracts\UniqueTranslationInterface; |
|
34
|
|
|
use Omatech\Mage\Core\Domains\Translations\Contracts\UpdateTranslationInterface; |
|
35
|
|
|
use Omatech\Mage\Core\Domains\Translations\Translation; |
|
36
|
|
|
use Omatech\Mage\Core\Domains\Users\Contracts\AllUserInterface; |
|
37
|
|
|
use Omatech\Mage\Core\Domains\Users\Contracts\CreateUserInterface; |
|
38
|
|
|
use Omatech\Mage\Core\Domains\Users\Contracts\DeleteUserInterface; |
|
39
|
|
|
use Omatech\Mage\Core\Domains\Users\Contracts\ExistsUserInterface; |
|
40
|
|
|
use Omatech\Mage\Core\Domains\Users\Contracts\FindUserInterface; |
|
41
|
|
|
use Omatech\Mage\Core\Domains\Users\Contracts\UniqueUserInterface; |
|
42
|
|
|
use Omatech\Mage\Core\Domains\Users\Contracts\UpdateUserInterface; |
|
43
|
|
|
use Omatech\Mage\Core\Domains\Users\Contracts\UserInterface; |
|
44
|
|
|
use Omatech\Mage\Core\Domains\Users\User; |
|
45
|
|
|
use Omatech\Mage\Core\Repositories\PermissionRepository; |
|
46
|
|
|
use Omatech\Mage\Core\Repositories\RoleRepository; |
|
47
|
|
|
use Omatech\Mage\Core\Repositories\TranslationRepository; |
|
48
|
|
|
use Omatech\Mage\Core\Repositories\UserRepository; |
|
49
|
|
|
|
|
50
|
|
|
class MageServiceProvider extends ServiceProvider |
|
51
|
|
|
{ |
|
52
|
|
|
/** |
|
53
|
|
|
* Bootstrap the application services. |
|
54
|
|
|
*/ |
|
55
|
74 |
|
public function boot() |
|
56
|
|
|
{ |
|
57
|
74 |
|
$this->permissionBindings(); |
|
58
|
74 |
|
$this->roleBindings(); |
|
59
|
74 |
|
$this->userBindings(); |
|
60
|
74 |
|
$this->translationBindings(); |
|
61
|
|
|
|
|
62
|
|
|
$this->app->bind('mage.permissions', function () { |
|
63
|
1 |
|
return new Permission(); |
|
64
|
74 |
|
}); |
|
65
|
|
|
|
|
66
|
|
|
$this->app->bind('mage.roles', function () { |
|
67
|
1 |
|
return new Role(); |
|
68
|
74 |
|
}); |
|
69
|
|
|
|
|
70
|
|
|
$this->app->bind('mage.users', function () { |
|
71
|
1 |
|
return new User(); |
|
72
|
74 |
|
}); |
|
73
|
|
|
|
|
74
|
|
|
$this->app->bind('mage.translations', function () { |
|
75
|
1 |
|
return new Translation(); |
|
76
|
74 |
|
}); |
|
77
|
|
|
|
|
78
|
74 |
|
$this->publishes($this->migrations(), 'mage-migrations'); |
|
79
|
74 |
|
} |
|
80
|
|
|
|
|
81
|
74 |
|
private function permissionBindings() |
|
82
|
|
|
{ |
|
83
|
74 |
|
$this->app->bind(PermissionInterface::class, Permission::class); |
|
84
|
74 |
|
$this->app->bind(AllPermissionInterface::class, PermissionRepository::class); |
|
85
|
74 |
|
$this->app->bind(FindPermissionInterface::class, PermissionRepository::class); |
|
86
|
74 |
|
$this->app->bind(CreatePermissionInterface::class, PermissionRepository::class); |
|
87
|
74 |
|
$this->app->bind(DeletePermissionInterface::class, PermissionRepository::class); |
|
88
|
74 |
|
$this->app->bind(ExistsPermissionInterface::class, PermissionRepository::class); |
|
89
|
74 |
|
$this->app->bind(UpdatePermissionInterface::class, PermissionRepository::class); |
|
90
|
74 |
|
$this->app->bind(UniquePermissionInterface::class, PermissionRepository::class); |
|
91
|
74 |
|
$this->app->bind(AttachedPermissionInterface::class, PermissionRepository::class); |
|
92
|
74 |
|
} |
|
93
|
|
|
|
|
94
|
74 |
|
private function roleBindings() |
|
95
|
|
|
{ |
|
96
|
74 |
|
$this->app->bind(RoleInterface::class, Role::class); |
|
97
|
74 |
|
$this->app->bind(AllRoleInterface::class, RoleRepository::class); |
|
98
|
74 |
|
$this->app->bind(FindRoleInterface::class, RoleRepository::class); |
|
99
|
74 |
|
$this->app->bind(CreateRoleInterface::class, RoleRepository::class); |
|
100
|
74 |
|
$this->app->bind(DeleteRoleInterface::class, RoleRepository::class); |
|
101
|
74 |
|
$this->app->bind(ExistsRoleInterface::class, RoleRepository::class); |
|
102
|
74 |
|
$this->app->bind(UpdateRoleInterface::class, RoleRepository::class); |
|
103
|
74 |
|
$this->app->bind(UniqueRoleInterface::class, RoleRepository::class); |
|
104
|
74 |
|
$this->app->bind(AttachedRoleInterface::class, RoleRepository::class); |
|
105
|
74 |
|
} |
|
106
|
|
|
|
|
107
|
74 |
|
private function userBindings() |
|
108
|
|
|
{ |
|
109
|
74 |
|
$this->app->bind(UserInterface::class, User::class); |
|
110
|
74 |
|
$this->app->bind(AllUserInterface::class, UserRepository::class); |
|
111
|
74 |
|
$this->app->bind(FindUserInterface::class, UserRepository::class); |
|
112
|
74 |
|
$this->app->bind(CreateUserInterface::class, UserRepository::class); |
|
113
|
74 |
|
$this->app->bind(DeleteUserInterface::class, UserRepository::class); |
|
114
|
74 |
|
$this->app->bind(ExistsUserInterface::class, UserRepository::class); |
|
115
|
74 |
|
$this->app->bind(UpdateUserInterface::class, UserRepository::class); |
|
116
|
74 |
|
$this->app->bind(UniqueUserInterface::class, UserRepository::class); |
|
117
|
74 |
|
} |
|
118
|
|
|
|
|
119
|
74 |
|
private function translationBindings() |
|
120
|
|
|
{ |
|
121
|
74 |
|
$this->app->bind(TranslationInterface::class, Translation::class); |
|
122
|
74 |
|
$this->app->bind(AllTranslationInterface::class, TranslationRepository::class); |
|
123
|
74 |
|
$this->app->bind(FindTranslationInterface::class, TranslationRepository::class); |
|
124
|
74 |
|
$this->app->bind(CreateTranslationInterface::class, TranslationRepository::class); |
|
125
|
74 |
|
$this->app->bind(DeleteTranslationInterface::class, TranslationRepository::class); |
|
126
|
74 |
|
$this->app->bind(ExistsTranslationInterface::class, TranslationRepository::class); |
|
127
|
74 |
|
$this->app->bind(UpdateTranslationInterface::class, TranslationRepository::class); |
|
128
|
74 |
|
$this->app->bind(UniqueTranslationInterface::class, TranslationRepository::class); |
|
129
|
74 |
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* Register the application services. |
|
133
|
|
|
*/ |
|
134
|
74 |
|
public function register() |
|
135
|
|
|
{ |
|
136
|
74 |
|
$this->mergeConfigFrom( |
|
137
|
74 |
|
__DIR__.'/../config/config.php', |
|
138
|
74 |
|
'mage' |
|
139
|
|
|
); |
|
140
|
|
|
|
|
141
|
74 |
|
$this->mergeConfigFrom( |
|
142
|
74 |
|
__DIR__.'/../config/permission.php', |
|
143
|
74 |
|
'permission' |
|
144
|
|
|
); |
|
145
|
|
|
|
|
146
|
74 |
|
$this->mergeConfigFrom( |
|
147
|
74 |
|
__DIR__.'/../config/auth.providers.php', |
|
148
|
74 |
|
'auth.providers' |
|
149
|
|
|
); |
|
150
|
|
|
|
|
151
|
74 |
|
$this->mergeConfigFrom( |
|
152
|
74 |
|
__DIR__.'/../config/auth.guards.php', |
|
153
|
74 |
|
'auth.guards' |
|
154
|
|
|
); |
|
155
|
|
|
|
|
156
|
74 |
|
$this->mergeConfigFrom( |
|
157
|
74 |
|
__DIR__.'/../config/translation-loader.php', |
|
158
|
74 |
|
'translation-loader' |
|
159
|
|
|
); |
|
160
|
74 |
|
} |
|
161
|
|
|
|
|
162
|
74 |
|
public function migrations() |
|
163
|
|
|
{ |
|
164
|
74 |
|
$migrations = []; |
|
165
|
|
|
|
|
166
|
74 |
|
$filesystem = new Filesystem(); |
|
167
|
74 |
|
$source = __DIR__.'/database/migrations/'; |
|
168
|
74 |
|
$destination = $this->app->databasePath().DIRECTORY_SEPARATOR.'migrations'.DIRECTORY_SEPARATOR; |
|
169
|
|
|
|
|
170
|
74 |
|
foreach ($filesystem->files($source) as $index => $file) { |
|
171
|
74 |
|
$sourceFileName = $file->getFilename(); |
|
172
|
74 |
|
$migrationName = substr($sourceFileName, 18, strlen($sourceFileName)); |
|
173
|
|
|
|
|
174
|
74 |
|
$fileExists = 0 != count($filesystem->glob($destination.'*'.$migrationName)); |
|
175
|
|
|
|
|
176
|
74 |
|
if (! $fileExists) { |
|
177
|
1 |
|
$destinationFileName = date('Y_m_d').'_'.str_pad($index, 6, '0').'_'.$migrationName; |
|
178
|
74 |
|
$migrations[$source.$sourceFileName] = $destination.$destinationFileName; |
|
179
|
|
|
} |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
74 |
|
return $migrations; |
|
183
|
|
|
} |
|
184
|
|
|
} |
|
185
|
|
|
|