InlineTranslationServiceProvider::addRoute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace BeyondCode\InlineTranslation;
4
5
use Illuminate\Contracts\Http\Kernel;
6
use Illuminate\Support\ServiceProvider;
7
8
class InlineTranslationServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     */
13
    public function boot()
14
    {
15
        if ($this->app->runningInConsole()) {
16
            $this->publishes([
17
                __DIR__.'/../config/config.php' => config_path('inline-translation.php'),
18
            ], 'config');
19
        }
20
21
        $this->loadTranslationsFrom(__DIR__.'/translations', 'laravel-inline-translation');
22
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'inline-translation');
23
24
        $this->registerMiddleware(InlineTranslationMiddleware::class);
25
26
        $this->addRoute();
27
    }
28
29
    /**
30
     * Register the application services.
31
     */
32
    public function register()
33
    {
34
        $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'inline-translation');
35
36
        $this->app->singleton(InlineTranslation::class);
37
    }
38
39
40
    /**
41
     * Register the middleware
42
     *
43
     * @param  string $middleware
44
     */
45
    protected function registerMiddleware($middleware)
46
    {
47
        $kernel = $this->app[Kernel::class];
48
        $kernel->pushMiddleware($middleware);
49
    }
50
51
    protected function addRoute()
52
    {
53
        app('router')->post('/_beyondcode/translation', InlineTranslationController::class.'@store');
54
    }
55
}
56