Completed
Pull Request — master (#13)
by
unknown
01:43
created

LocalizerServiceProvider::boot()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 25
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
rs 8.8571
cc 3
eloc 16
nc 4
nop 1
1
<?php
2
3
namespace Aitor24\Localizer;
4
5
use Illuminate\Support\ServiceProvider;
6
use Unicodeveloper\Identify\IdentifyServiceProvider;
7
8
class LocalizerServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     *
13
     * @return void
14
     */
15
    public function boot(\Illuminate\Routing\Router $router)
16
    {
17
        if (!$this->app->routesAreCached()) {
18
            require __DIR__.'/Routes/web.php';
19
        }
20
21
        $this->publishes([
22
            __DIR__.'/Config/localizer.php' => config_path('localizer.php'),
23
        ], 'localizer_config');
24
25
        $this->publishes([
26
            __DIR__.'/Config/localizer_languages.php' => config_path('localizer_languages.php'),
27
        ], 'localizer_languages');
28
29
        $router->aliasMiddleware('localizer', config('localizer.middleware'));
30
        $this->app->register(IdentifyServiceProvider::class);
31
32
        if (! class_exists('AddLocaleColumn')) {
33
            // Publish the migration
34
            $timestamp = date('Y_m_d_His', time());
35
            $this->publishes([
36
                __DIR__.'/Migrations/add_locale_column.php.stub' => $this->app->databasePath().'/migrations/'.$timestamp.'_add_locale_column.php',
0 ignored issues
show
Bug introduced by
The method databasePath() does not exist on Illuminate\Contracts\Foundation\Application. Did you maybe mean basePath()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
37
            ], 'localizer_migrations');
38
        }
39
    }
40
41
    /**
42
     * Register the application services.
43
     *
44
     * @return void
45
     */
46
    public function register()
47
    {
48
        $this->mergeConfigFrom(__DIR__.'/Config/localizer.php', 'localizer');
49
        $this->mergeConfigFrom(__DIR__.'/Config/localizer_languages.php', 'localizer_languages');
50
    }
51
}
52