Issues (25)

src/MailEclipseServiceProvider.php (1 issue)

Severity
1
<?php
2
3
namespace Qoraiche\MailEclipse;
4
5
use Illuminate\Support\Facades\Route;
6
use Illuminate\Support\ServiceProvider;
7
use Qoraiche\MailEclipse\Command\VendorPublishCommand;
8
9
class MailEclipseServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Perform post-registration booting of services.
13
     *
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        Route::middlewareGroup('maileclipse', config('maileclipse.middlewares', []));
19
20
        $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'maileclipse');
21
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'maileclipse');
22
        $this->registerRoutes();
23
24
        // Publishing is only necessary when using the CLI.
25
        if ($this->app->runningInConsole()) {
26
            $this->bootForConsole();
27
        }
28
    }
29
30
    /**
31
     * Register the package routes.
32
     *
33
     * @return void
34
     */
35
    private function registerRoutes()
36
    {
37
        Route::group($this->routeConfiguration(), function () {
38
            $this->loadRoutesFrom(__DIR__.'/Http/routes.php');
39
        });
40
    }
41
42
    /**
43
     * Get the Telescope route group configuration array.
44
     *
45
     * @return array
46
     */
47
    private function routeConfiguration()
48
    {
49
        return [
50
            'namespace' => 'Qoraiche\MailEclipse\Http\Controllers',
51
            'prefix' => config('maileclipse.path'),
52
            'middleware' => 'maileclipse',
53
        ];
54
    }
55
56
    /**
57
     * Register any package services.
58
     *
59
     * @return void
60
     */
61
    public function register()
62
    {
63
        $this->mergeConfigFrom(__DIR__.'/../config/maileclipse.php', 'maileclipse');
64
65
        // Register the service the package provides.
66
        $this->app->singleton('maileclipse', function ($app) {
0 ignored issues
show
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

66
        $this->app->singleton('maileclipse', function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
67
            return new MailEclipse;
68
        });
69
    }
70
71
    /**
72
     * Get the services provided by the provider.
73
     *
74
     * @return array
75
     */
76
    public function provides()
77
    {
78
        return ['maileclipse'];
79
    }
80
81
    /**
82
     * Console-specific booting.
83
     *
84
     * @return void
85
     */
86
    protected function bootForConsole()
87
    {
88
        // Publishing the configuration file.
89
        $this->publishes([
90
            __DIR__.'/../config/maileclipse.php' => config_path('maileclipse.php'),
91
        ], 'maileclipse.config');
92
93
        $this->publishes([
94
            __DIR__.'/../public' => public_path('vendor/maileclipse'),
95
        ], 'public');
96
97
        $this->publishes([
98
            __DIR__.'/../resources/views/templates' => $this->app->resourcePath('views/vendor/maileclipse/templates'),
99
        ], 'maileclipse.templates');
100
101
        // Add Artisan publish command
102
        $this->commands([
103
            VendorPublishCommand::class,
104
        ]);
105
    }
106
}
107