Test Failed
Push — master ( 5904eb...0e6af8 )
by Phaniraj
05:25
created

ImportExportServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 26
dl 0
loc 77
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 18 1
A boot() 0 34 2
A provides() 0 3 1
1
<?php
2
3
namespace LWS\ImportExport;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class ImportExportServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Bootstrap the application services.
11
     *
12
     * @return void
13
     */
14
    public function boot()
15
    {
16
        // Register routes
17
        $this->loadRoutesFrom(__DIR__.'/routes.php');
18
19
        // Register database migrations
20
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
21
22
        // Load views
23
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'importexport');
24
25
        // $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'LWS');
26
27
        // Publishing is only necessary when using the CLI.
28
        if ($this->app->runningInConsole()) {
29
30
            // Publishing the configuration file.
31
            $this->publishes([
32
                __DIR__.'/../config/import.php' => config_path('ladybirdweb/import-export/import.php'),
33
            ], 'import-export.config');
34
35
            $this->publishes([
36
                __DIR__.'/../config/export.php' => config_path('ladybirdweb/import-export/export.php'),
37
            ], 'import-export.config');
38
39
            // Publishing the views.
40
            $this->publishes([
41
                __DIR__.'/../resources/views' => base_path('resources/views/vendor/ladybirdweb/import-export'),
42
            ], 'import-export.views');
43
44
            // Publishing assets.
45
            $this->publishes([
46
                __DIR__.'/../public/assets' => public_path('vendor/ladybirdweb/import-export'),
47
            ], 'import-export.assets');
48
        }
49
    }
50
51
    /**
52
     * Register the application services.
53
     *
54
     * @return void
55
     */
56
    public function register()
57
    {
58
        // Merge config
59
        $this->mergeConfigFrom(__DIR__.'/../config/import.php', 'import');
60
        $this->mergeConfigFrom(__DIR__.'/../config/export.php', 'export');
61
62
        // Register fecades
63
        $this->app->singleton('import', 'Ladybirdweb\ImportExport\Import');
64
        $this->app->singleton('importhandler', 'Ladybirdweb\ImportExport\ImportHandler');
65
        $this->app->singleton('importexportlog', 'Ladybirdweb\ImportExport\ImportExportLog');
66
67
        $this->app->singleton('export', 'Ladybirdweb\ImportExport\Export');
68
69
        // Register import controller
70
        $this->app->singleton('Ladybirdweb\ImportExport\Import');
71
72
        // Register import handler
73
        $this->app->singleton('Ladybirdweb\ImportExport\ImportHandler');
74
    }
75
76
    /**
77
     * Get the services provided by the provider.
78
     *
79
     * @return array
80
     */
81
    public function provides()
82
    {
83
        return ['ImportExport'];
84
    }
85
}
86