-
Notifications
You must be signed in to change notification settings - Fork 7
/
LighthouseSanctumServiceProvider.php
82 lines (66 loc) · 2.51 KB
/
LighthouseSanctumServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
declare(strict_types=1);
namespace DanielDeWit\LighthouseSanctum\Providers;
use DanielDeWit\LighthouseSanctum\Contracts\Services\EmailVerificationServiceInterface;
use DanielDeWit\LighthouseSanctum\Contracts\Services\ResetPasswordServiceInterface;
use DanielDeWit\LighthouseSanctum\Enums\EmailVerificationStatus;
use DanielDeWit\LighthouseSanctum\Enums\ForgotPasswordStatus;
use DanielDeWit\LighthouseSanctum\Enums\LogoutStatus;
use DanielDeWit\LighthouseSanctum\Enums\RegisterStatus;
use DanielDeWit\LighthouseSanctum\Services\EmailVerificationService;
use DanielDeWit\LighthouseSanctum\Services\ResetPasswordService;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Support\ServiceProvider;
use Nuwave\Lighthouse\Schema\TypeRegistry;
use Nuwave\Lighthouse\Schema\Types\LaravelEnumType;
class LighthouseSanctumServiceProvider extends ServiceProvider
{
protected TypeRegistry $typeRegistry;
public function register(): void
{
$this->app->singleton(EmailVerificationServiceInterface::class, EmailVerificationService::class);
$this->app->singleton(ResetPasswordServiceInterface::class, ResetPasswordService::class);
}
public function boot(Dispatcher $dispatcher, TypeRegistry $typeRegistry): void
{
$this->typeRegistry = $typeRegistry;
$this->publishConfig();
$this->publishSchema();
$this->mergeConfig();
$this->registerEnums();
}
protected function publishConfig(): void
{
$this->publishes([
__DIR__ . '/../../config/lighthouse-sanctum.php' => config_path('lighthouse-sanctum.php'),
], 'lighthouse-sanctum');
}
protected function publishSchema(): void
{
$this->publishes([
__DIR__ . '/../../graphql/sanctum.graphql' => base_path('graphql/sanctum.graphql'),
], 'lighthouse-sanctum');
}
protected function mergeConfig(): void
{
$this->mergeConfigFrom(
__DIR__ . '/../../config/lighthouse-sanctum.php',
'lighthouse-sanctum',
);
}
protected function registerEnums(): void
{
$this->typeRegistry->register(
new LaravelEnumType(RegisterStatus::class),
);
$this->typeRegistry->register(
new LaravelEnumType(LogoutStatus::class),
);
$this->typeRegistry->register(
new LaravelEnumType(EmailVerificationStatus::class),
);
$this->typeRegistry->register(
new LaravelEnumType(ForgotPasswordStatus::class),
);
}
}