Completed
Push — develop ( fd7b2c...32742a )
by Stoea
01:56
created

LaravelMobilpayServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 81
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B boot() 0 61 2
A register() 0 10 1
1
<?php
2
3
namespace Stl30\LaravelMobilpay;
4
5
use App\Observers\TransactionsObserver;
6
use Illuminate\Support\Facades\Log;
7
use Illuminate\Support\ServiceProvider;
8
9
class LaravelMobilpayServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application services.
13
     */
14
    public function boot()
15
    {
16
        /*
17
         * Optional methods to load your package assets
18
         */
19
        $this->loadTranslationsFrom(__DIR__.'/resources/lang', 'laravel-mobilpay');
20
        $this->loadViewsFrom(__DIR__.'/resources/views', 'laravel-mobilpay');
21
        $this->loadMigrationsFrom(__DIR__.'/database/migrations');
22
        $this->loadRoutesFrom(__DIR__.'/routes/web.php');
23
24
        if ($this->app->runningInConsole()) {
25
            $this->publishes([
26
                __DIR__.'/config/laravel-mobilpay.php' => config_path('laravel-mobilpay.php'),
27
            ], 'config');
28
29
            // Publishing the views.
30
            $this->publishes([
31
                __DIR__.'/resources/views/laravel-mobilpay' => resource_path('views/vendor/laravel-mobilpay'),
32
            ], 'views');
33
34
            // Publishing assets.
35
            $this->publishes([
36
                __DIR__.'/resources/assets' => public_path('vendor/laravel-mobilpay'),
37
            ], 'assets');
38
39
            // Publishing the translation files.
40
            $this->publishes([
41
                __DIR__.'/resources/lang' => resource_path('lang/vendor/laravel-mobilpay'),
42
            ], 'lang');
43
44
45
            // Publishing Observes files.
46
            //if you want to use observers uncoment below 
47
//            $this->publishes([
48
//                __DIR__.'/Observers' => app_path('Observers'),
49
//            ]);
50
            
51
            // Publishing custom classes files.
52
            $this->publishes([
53
                __DIR__.'/LaravelMobilpay' => app_path('LaravelMobilpay'),
54
            ]);
55
56
            // Registering package commands.
57
            // $this->commands([]);
58
        }
59
        
60
//        if you want to use observers uncoment below
61
//        if(config('laravel-mobilpay.transaction_observer_active')){
62
//
63
//            try {
64
//                if(class_exists('App\Observers\TransactionsObserver')){
65
//                    MobilpayTransaction::observe(TransactionsObserver::class);
66
//                }
67
//                else{
68
//                    Log::debug(__METHOD__.' Transactions observer does not exist');
69
//                }
70
//            } catch (Exception $e) {
71
//            }
72
//
73
//        }
74
    }
75
76
    /**
77
     * Register the application services.
78
     */
79
    public function register()
80
    {
81
        // Automatically apply the package configuration
82
        $this->mergeConfigFrom(__DIR__ . '/config/laravel-mobilpay.php', 'laravel-mobilpay');
83
84
        // Register the main class to use with the facade
85
        $this->app->singleton('laravel-mobilpay', function () {
86
            return new LaravelMobilpay;
87
        });
88
    }
89
}
90