|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Milkmeowo\Framework\Base\Providers; |
|
4
|
|
|
|
|
5
|
|
|
use Clockwork\Support\Laravel\ClockworkMiddleware; |
|
6
|
|
|
use Clockwork\Support\Laravel\ClockworkServiceProvider; |
|
7
|
|
|
use Barryvdh\Cors\ServiceProvider as CorsServiceProvider; |
|
8
|
|
|
use Dingo\Api\Provider\LaravelServiceProvider as DingoLaravel; |
|
9
|
|
|
use Dingo\Api\Http\Middleware\Request as DingoMiddlewareRequest; |
|
10
|
|
|
use Milkmeowo\Framework\Dingo\Providers\LaravelEventsServiceProvider as DingoEvents; |
|
11
|
|
|
use Milkmeowo\Framework\Dingo\Providers\ExceptionHandlerServiceProvider as DingoExceptionHandler; |
|
12
|
|
|
|
|
13
|
|
|
class LaravelServiceProvider extends BaseServiceProvider |
|
14
|
|
|
{ |
|
15
|
|
|
public function boot() |
|
16
|
|
|
{ |
|
17
|
|
|
parent::boot(); |
|
18
|
|
|
|
|
19
|
|
|
$this->bootMiddleware(); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
protected function bootMiddleware() |
|
23
|
|
|
{ |
|
24
|
|
|
$httpKernel = app('Illuminate\Contracts\Http\Kernel'); |
|
25
|
|
|
// Global middleware |
|
26
|
|
|
if ($this->app->environment() !== 'production') { |
|
27
|
|
|
$httpKernel->pushMiddleware( |
|
28
|
|
|
ClockworkMiddleware::class |
|
29
|
|
|
); |
|
30
|
|
|
// Register into dingo api middleware |
|
31
|
|
|
$this->app[DingoMiddlewareRequest::class]->mergeMiddlewares([ |
|
32
|
|
|
'clockwork' => ClockworkMiddleware::class, |
|
33
|
|
|
]); |
|
34
|
|
|
} |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function register() |
|
38
|
|
|
{ |
|
39
|
|
|
parent::register(); |
|
40
|
|
|
|
|
41
|
|
|
$this->registerDingo(); |
|
42
|
|
|
|
|
43
|
|
|
$this->registerClockwork(); |
|
44
|
|
|
|
|
45
|
|
|
$this->registerCors(); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
protected function registerClockwork() |
|
49
|
|
|
{ |
|
50
|
|
|
if ($this->app->environment() !== 'production') { |
|
51
|
|
|
$this->app->register(ClockworkServiceProvider::class); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
protected function registerDingo() |
|
56
|
|
|
{ |
|
57
|
|
|
// dingo api |
|
58
|
|
|
$this->app->register(DingoLaravel::class); |
|
59
|
|
|
$this->app->register(DingoExceptionHandler::class); |
|
60
|
|
|
$this->app->register(DingoEvents::class); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
protected function registerCors() |
|
64
|
|
|
{ |
|
65
|
|
|
$this->app->register(CorsServiceProvider::class); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|