-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathServiceProvider.php
More file actions
59 lines (48 loc) · 1.6 KB
/
ServiceProvider.php
File metadata and controls
59 lines (48 loc) · 1.6 KB
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
<?php namespace Api;
use App;
use Config;
use Api\Classes\SchemaManager;
use Api\Classes\SchemaSourceProvider;
use Nuwave\Lighthouse\Schema\Directives\BaseDirective;
use October\Rain\Support\ModuleServiceProvider;
class ServiceProvider extends ModuleServiceProvider
{
public function register()
{
parent::register('api');
$this->registerProviders();
$this->registerConfig();
$this->registerMiddlewares();
$this->registerSingletons();
App::make('October\Rain\Support\ClassLoader')->addDirectories(base_path('graphql'));
SchemaManager::instance()->registerModelNamespaces();
}
public function boot()
{
parent::boot('api');
$this->publishes([
__DIR__.'/config/config.php' => config_path('api.php'),
__DIR__.'/assets/schema.graphql' => base_path('graphql/schema.graphql'),
]);
}
public function registerConfig()
{
$config = Config::get('api.lighthouse');
Config::set('lighthouse', $config);
$config = Config::get('api.graphql-playground');
Config::set('graphql-playground', $config);
}
public function registerProviders()
{
App::register('Nuwave\Lighthouse\LighthouseServiceProvider');
App::register("MLL\GraphQLPlayground\GraphQLPlaygroundServiceProvider");
}
public function registerSingletons()
{
App::singleton(\Nuwave\Lighthouse\Schema\Source\SchemaSourceProvider::class, \Api\Classes\SchemaSourceProvider::class);
}
public function registerMiddlewares()
{
$this->app['router']->aliasMiddleware('api-checkauth', \Api\Middleware\CheckAuth::class);
}
}