Completed
Push — master ( 6ec982...5e22c4 )
by Pásztor
12:30
created

Plugin::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Autumn\JWTAuth;
4
5
use App;
6
use Illuminate\Foundation\AliasLoader;
7
use System\Classes\PluginBase;
8
9
/**
10
 * JWTAuth Plugin Information File.
11
 */
12
class Plugin extends PluginBase
13
{
14
    /**
15
     * @var array Plugin dependencies
16
     */
17
    public $require = ['RainLab.User'];
18
19
    /**
20
     * Returns information about this plugin.
21
     *
22
     * @return array
23
     */
24
    public function pluginDetails()
25
    {
26
        return [
27
            'name'        => 'JWTAuth',
28
            'description' => 'JSON Web Token Authentication.',
29
            'author'      => 'Autumn',
30
            'icon'        => 'icon-user-secret',
31
        ];
32
    }
33
34
    /**
35
     * Register method, called when the plugin is first registered.
36
     *
37
     * @return void
38
     */
39
    public function register()
40
    {
41
        $this->app['config']['jwt'] = require(__DIR__.'/config/jwt.php');
42
        $this->app['config']['api'] = require(__DIR__.'/config/api.php');
43
44
        $this->app->register(\Dingo\Api\Provider\LaravelServiceProvider::class);
45
        $this->app->register(\Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class);
46
47
        $alias = AliasLoader::getInstance();
48
        $alias->alias('JWTAuth', \Tymon\JWTAuth\Facades\JWTAuth::class);
49
        $alias->alias('JWTFactory', \Tymon\JWTAuth\Facades\JWTFactory::class);
50
    }
51
52
    /**
53
     * Boot method, called right before the request route.
54
     *
55
     * @return array
56
     */
57
    public function boot()
58
    {
59
        $this->app->register(\Autumn\JWTAuth\Providers\JWTServiceProvider::class);
60
61
        $this->app['Dingo\Api\Auth\Auth']->extend('jwt', function ($app) {
62
            return new \Dingo\Api\Auth\Provider\JWT($app['Tymon\JWTAuth\JWTAuth']);
63
        });
64
    }
65
}
66