AuthorizerServiceProvider.php 1.21 KB
Newer Older
1
2
3
4
5
<?php


namespace Source\Authorization;

6
use App\Guards\ApiGuard;
7
use Illuminate\Foundation\Application;
Jacob Priddy's avatar
Jacob Priddy committed
8
use Illuminate\Support\ServiceProvider;
9
10
use Source\Gateways\Users\UsersRepository;
use Source\Gateways\Groups\GroupsRepository;
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use Source\Gateways\GroupUser\GroupUserRepository;
use Illuminate\Contracts\Support\DeferrableProvider;

/**
 * Service provider must be registered in AppServiceProvider
 */
class AuthorizerServiceProvider extends ServiceProvider implements DeferrableProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
Jacob Priddy's avatar
Jacob Priddy committed
26
        $this->app->singleton(Authorizer::class, static function (Application $app) {
27
            return new ApiAuthorizer(
28
                $app->make(ApiGuard::class)->id(),
29
30
31
32
                $app->make(UsersRepository::class),
                $app->make(GroupsRepository::class),
                $app->make(GroupUserRepository::class)
            );
33
34
35
36
37
38
39
40
        });
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
Jacob Priddy's avatar
Jacob Priddy committed
41
42
    public function boot(): void
    {
43
44
45
46
47
48
49
50
51
52
    }

    /**
     * @return array
     */
    public function provides()
    {
        return [Authorizer::class];
    }
}