|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* @author enea dhack <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Enea\Authorization; |
|
13
|
|
|
|
|
14
|
|
|
use Enea\Authorization\Blade\Compiler; |
|
15
|
|
|
use Enea\Authorization\Commands\InstallCommand; |
|
16
|
|
|
use Enea\Authorization\Contracts\PermissionContract; |
|
17
|
|
|
use Enea\Authorization\Contracts\RoleContract; |
|
18
|
|
|
use Enea\Authorization\Resolvers\DriverResolver; |
|
19
|
|
|
use Enea\Authorization\Support\Config; |
|
20
|
|
|
use Enea\Authorization\Support\Helper; |
|
21
|
|
|
use Illuminate\Support\ServiceProvider; |
|
22
|
|
|
|
|
23
|
|
|
class AuthorizationServiceProvider extends ServiceProvider |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* Bootstrap the application services. |
|
27
|
|
|
* |
|
28
|
|
|
* @return void |
|
29
|
|
|
*/ |
|
30
|
85 |
|
public function boot(): void |
|
31
|
|
|
{ |
|
32
|
85 |
|
$this->publish(); |
|
33
|
85 |
|
$this->registerBladeDirectives(); |
|
34
|
85 |
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Register the application services. |
|
38
|
|
|
* |
|
39
|
|
|
* @return void |
|
40
|
|
|
*/ |
|
41
|
85 |
|
public function register(): void |
|
42
|
|
|
{ |
|
43
|
85 |
|
$this->app->register(EventServiceProvider::class); |
|
44
|
|
|
|
|
45
|
85 |
|
$this->commands([ |
|
46
|
85 |
|
InstallCommand::class |
|
47
|
|
|
]); |
|
48
|
|
|
|
|
49
|
85 |
|
$this->registerBindings(); |
|
50
|
85 |
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* {@inheritdoc} |
|
54
|
|
|
*/ |
|
55
|
|
|
public function provides() |
|
56
|
|
|
{ |
|
57
|
|
|
return [ |
|
58
|
|
|
Authorizer::class, |
|
59
|
|
|
]; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
85 |
|
private function publish(): void |
|
63
|
|
|
{ |
|
64
|
85 |
|
$this->publishes([ |
|
65
|
85 |
|
__DIR__ . '/../config/authorization.php' => base_path('config/authorization.php') |
|
66
|
|
|
]); |
|
67
|
85 |
|
} |
|
68
|
|
|
|
|
69
|
85 |
|
private function registerBindings(): void |
|
70
|
|
|
{ |
|
71
|
85 |
|
$this->configDriver(); |
|
72
|
85 |
|
$this->app->bind(PermissionContract::class, Config::permissionModel()); |
|
73
|
85 |
|
$this->app->bind(RoleContract::class, Config::roleModel()); |
|
74
|
85 |
|
$this->app->singleton('authorization.helpers', Helper::class); |
|
75
|
85 |
|
} |
|
76
|
|
|
|
|
77
|
85 |
|
private function configDriver(): void |
|
78
|
|
|
{ |
|
79
|
85 |
|
(new DriverResolver($this->app))->make(); |
|
80
|
85 |
|
} |
|
81
|
|
|
|
|
82
|
85 |
|
private function registerBladeDirectives(): void |
|
83
|
|
|
{ |
|
84
|
85 |
|
(new Compiler())->make(); |
|
85
|
85 |
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|