Completed
Push — master ( 928d8a...2f7023 )
by Arjay
07:15
created

DataTablesServiceProvider::provides()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Yajra\DataTables;
4
5
use Illuminate\Support\ServiceProvider;
6
use Yajra\DataTables\Utilities\Config;
7
use Yajra\DataTables\Utilities\Request;
8
9
class DataTablesServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Indicates if loading of the provider is deferred.
13
     *
14
     * @var bool
15
     */
16
    protected $defer = false;
17
18
    /**
19
     * Bootstrap the application events.
20
     *
21
     * @return void
22
     */
23
    public function boot()
24
    {
25
        $this->mergeConfigFrom(__DIR__ . '/config/datatables.php', 'datatables');
26
27
        $this->publishes([
28
            __DIR__ . '/config/datatables.php' => config_path('datatables.php'),
29
        ], 'datatables');
30
    }
31
32
    /**
33
     * Register the service provider.
34
     *
35
     * @return void
36
     */
37
    public function register()
38
    {
39
        if ($this->isLumen()) {
40
            require_once 'fallback.php';
41
        }
42
43
        $this->app->alias('datatables', Factory::class);
44
        $this->app->singleton('datatables', function () {
45
            return new Factory;
46
        });
47
48
        $this->app->singleton('datatables.request', function () {
49
            return new Request;
50
        });
51
52
        $this->app->singleton('datatables.config', Config::class);
53
    }
54
55
    /**
56
     * Check if app uses Lumen.
57
     *
58
     * @return bool
59
     */
60
    protected function isLumen()
61
    {
62
        return str_contains($this->app->version(), 'Lumen');
63
    }
64
65
    /**
66
     * Get the services provided by the provider.
67
     *
68
     * @return string[]
69
     */
70
    public function provides()
71
    {
72
        return [
73
            'datatables',
74
            'datatables.config',
75
            'datatables.request',
76
        ];
77
    }
78
}
79