Completed
Push — master ( db7479...0ca10e )
by Elf
02:08
created

DataTablesServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
b 0
f 0
lcom 1
cbo 2
dl 0
loc 57
ccs 0
cts 27
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 8 1
A registerOriginalDataTables() 0 7 1
A replaceDataTablesBindings() 0 4 1
A configureDataTables() 0 12 2
1
<?php
2
3
namespace ElfSundae\Laravel\DataTables;
4
5
use Illuminate\Foundation\AliasLoader;
6
use Illuminate\Support\ServiceProvider;
7
8
class DataTablesServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Register the service provider.
12
     *
13
     * @return void
14
     */
15
    public function register()
16
    {
17
        $this->registerOriginalDataTables();
18
19
        $this->replaceDataTablesBindings();
20
21
        $this->configureDataTables();
22
    }
23
24
    /**
25
     * Register the original DataTables service providers.
26
     *
27
     * @return void
28
     */
29
    protected function registerOriginalDataTables()
30
    {
31
        $this->app->register(\Yajra\DataTables\DataTablesServiceProvider::class);
32
        AliasLoader::getInstance()->alias('DataTables', \Yajra\DataTables\Facades\DataTables::class);
33
34
        $this->app->register(\Yajra\DataTables\ButtonsServiceProvider::class);
35
    }
36
37
    /**
38
     * Replace the original DataTables bindings.
39
     *
40
     * @return void
41
     */
42
    protected function replaceDataTablesBindings()
43
    {
44
        $this->app->bind('datatables.html', Html\Builder::class);
45
    }
46
47
    /**
48
     * Configure DataTables.
49
     *
50
     * @return void
51
     */
52
    protected function configureDataTables()
53
    {
54
        $this->app['config']->set([
55
            'datatables.engines.eloquent' => EloquentDataTable::class,
56
        ]);
57
58
        if (! $this->app['config']->has('datatables-buttons.stub')) {
59
            $this->app['config']->set([
60
                'datatables-buttons.stub' => '/vendor/elfsundae/laravel-datatables/src/stubs',
61
            ]);
62
        }
63
    }
64
}
65