Completed
Pull Request — master (#1)
by Elf
03:46 queued 02:36
created

DatatablesServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 42
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 6 1
A registerOriginalDataTables() 0 7 1
A replaceDataTablesBindings() 0 9 1
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
22
    /**
23
     * Register the original DataTables service providers.
24
     *
25
     * @return void
26
     */
27
    protected function registerOriginalDataTables()
28
    {
29
        $this->app->register(\Yajra\DataTables\DataTablesServiceProvider::class);
30
        AliasLoader::getInstance()->alias('DataTables', \Yajra\DataTables\Facades\DataTables::class);
31
32
        $this->app->register(\Yajra\DataTables\ButtonsServiceProvider::class);
33
    }
34
35
    /**
36
     * Replace the original DataTables bindings.
37
     *
38
     * @return void
39
     */
40
    protected function replaceDataTablesBindings()
41
    {
42
        $this->app->alias('datatables', DataTables::class);
43
        $this->app->singleton('datatables', function () {
44
            return new DataTables;
45
        });
46
47
        $this->app->bind('datatables.html', Html\Builder::class);
48
    }
49
}
50