Issues (65)

src/ModuleServiceProvider.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Rawilk\LaravelModules;
4
5
use Illuminate\Support\ServiceProvider;
6
use Rawilk\LaravelModules\Contracts\ModuleModel;
7
use Rawilk\LaravelModules\Contracts\Repository;
8
use Rawilk\LaravelModules\Providers\BootstrapServiceProvider;
9
use Rawilk\LaravelModules\Providers\ConsoleServiceProvider;
10
use Rawilk\LaravelModules\Providers\ContractServiceProvider;
11
12
abstract class ModuleServiceProvider extends ServiceProvider
13
{
14
    abstract protected function registerServices(): void;
15
16
    public function provides(): array
17
    {
18
        return [Repository::class, 'modules'];
19
    }
20
21
    protected function publishMigrations(): void
22
    {
23
        if (! class_exists('CreateModulesTable')) {
24
            $this->publishes([
25
                __DIR__ . '/../database/migrations/create_modules_table.php.stub' => database_path('migrations/' . date('Y_m_d_His') . '_create_modules_table.php')
26
            ], 'migrations');
27
        }
28
    }
29
30
    protected function registerModules(): void
31
    {
32
        $this->app->register(BootstrapServiceProvider::class);
33
    }
34
35
    protected function registerModuleModel(): void
36
    {
37
        $config = $this->app->config['modules.models'];
0 ignored issues
show
Accessing config on the interface Illuminate\Contracts\Foundation\Application suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
38
39
        $this->app->bind(ModuleModel::class, $config['module']);
40
    }
41
42
    protected function registerNamespaces(): void
43
    {
44
        $configPath = __DIR__ . '/../config/config.php';
45
46
        $this->mergeConfigFrom($configPath, 'modules');
47
        $this->publishes([
48
            $configPath => config_path('modules.php')
49
        ], 'config');
50
    }
51
52
    protected function registerProviders(): void
53
    {
54
        $this->app->register(ConsoleServiceProvider::class);
55
        $this->app->register(ContractServiceProvider::class);
56
    }
57
}
58