PdfTinkerServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 3
b 0
f 0
nc 1
nop 0
dl 0
loc 11
rs 10
1
<?php
2
3
namespace Traincase\LaravelPdfTinker;
4
5
use Illuminate\Support\ServiceProvider;
6
use Traincase\HtmlToPdfTinker\Drivers\DompdfDriver;
7
use Traincase\HtmlToPdfTinker\Drivers\WkhtmltopdfDriver;
8
use Traincase\HtmlToPdfTinker\PdfTinkerManager;
9
10
class PdfTinkerServiceProvider extends ServiceProvider
11
{
12
    public function register()
13
    {
14
        /** Bind the manager in the container, to allow addition of drivers */
15
        $this->app->singleton(PdfTinkerManager::class, function () {
16
            $manager = new PdfTinkerManager();
17
18
            $manager->extend('dompdf', function () {
19
                $dompdf = new \Dompdf\Dompdf();
20
                $dompdf->setBasePath(realpath(base_path('public')));
21
22
                return new DompdfDriver($dompdf);
23
            });
24
25
            $manager->extend('wkhtmltopdf', function () {
26
                return new WkhtmltopdfDriver(new \mikehaertl\wkhtmlto\Pdf);
27
            });
28
29
            return $manager;
30
        });
31
32
        /** Make sure we can type hint the Filesystem in our controller. */
33
        $this->app->bind(\League\Flysystem\Filesystem::class, function() {
34
            return new \League\Flysystem\Filesystem(
35
                new \League\Flysystem\Adapter\Local(storage_path('/'))
36
            );
37
        });
38
    }
39
40
    public function boot()
41
    {
42
        $this->loadViewsFrom(__DIR__ . '/../assets/views', 'laravel-pdf-tinker');
43
44
        $this->mergeConfigFrom(__DIR__ . '/../config/laravel-pdf-tinker.php', 'laravel-pdf-tinker');
45
46
        $this->loadRoutesFrom(__DIR__ . '/Http/routes.php');
47
48
        $this->publishes([
49
            __DIR__ . '/../config/laravel-pdf-tinker.php' => config_path('laravel-pdf-tinker.php'),
50
        ], 'laravel-pdf-tinker-config');
51
    }
52
}
53