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

replaceDataTablesBindings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 8
cp 0
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 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
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