• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visavi / rotor / 26602863997

28 May 2026 09:18PM UTC coverage: 14.625% (+0.07%) from 14.557%
26602863997

push

github

visavi
Закешил disk-scan модулей, schedule только в console, пустой результат не кешится.

14 of 60 new or added lines in 2 files covered. (23.33%)

1 existing line in 1 file now uncovered.

880 of 6017 relevant lines covered (14.63%)

1.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

8.06
/app/Providers/ModuleServiceProvider.php
1
<?php
2

3
namespace App\Providers;
4

5
use App\Classes\Registry;
6
use App\Classes\Restatement;
7
use App\Models\Module;
8
use Illuminate\Console\Scheduling\Schedule;
9
use Illuminate\Database\Eloquent\Relations\Relation;
10
use Illuminate\Routing\Router;
11
use Illuminate\Support\Facades\Config;
12
use Illuminate\Support\ServiceProvider;
13
use Illuminate\Support\Str;
14

15
class ModuleServiceProvider extends ServiceProvider
16
{
17
    /**
18
     * Register services.
19
     */
20
    public function register(): void
60✔
21
    {
22
        //
23
    }
60✔
24

25
    /**
26
     * Bootstrap services.
27
     */
28
    public function boot(Router $router): void
60✔
29
    {
30
        $modules = Module::getEnabledModules();
60✔
31

32
        foreach ($modules as $module => $data) {
60✔
NEW
33
            $files = $data['files'];
×
NEW
34
            $settings = $data['settings'];
×
NEW
35
            $base = base_path('modules/' . $module . '/');
×
UNCOV
36
            $moduleKey = Str::snake($module);
×
37

NEW
38
            if ($files['views']) {
×
NEW
39
                $this->loadViewsFrom($base . 'resources/views', $moduleKey);
×
40
            }
41

NEW
42
            if ($files['lang']) {
×
NEW
43
                $this->loadTranslationsFrom($base . 'resources/lang', $moduleKey);
×
44
            }
45

NEW
46
            if ($files['helpers']) {
×
NEW
47
                include_once $base . 'helpers.php';
×
48
            }
49

NEW
50
            if ($files['hooks']) {
×
NEW
51
                include_once $base . 'hooks.php';
×
52
            }
53

NEW
54
            if ($files['routes']) {
×
NEW
55
                $this->loadRoutesFrom($base . 'routes.php');
×
56
            }
57

NEW
58
            if ($files['config']) {
×
NEW
59
                $this->mergeConfigFrom($base . 'config.php', $moduleKey);
×
60

61
                if ($settings) {
×
62
                    Config::set($moduleKey, array_replace_recursive(
×
63
                        config($moduleKey, []),
×
64
                        $settings
×
65
                    ));
×
66
                }
67
            }
68

NEW
69
            if ($files['middleware']) {
×
NEW
70
                $middleware = include $base . 'middleware.php';
×
71

72
                foreach ($middleware['aliases'] ?? [] as $alias => $class) {
×
73
                    $router->aliasMiddleware($alias, $class);
×
74
                }
75

76
                foreach ($middleware['web'] ?? [] as $class) {
×
77
                    $router->pushMiddlewareToGroup('web', $class);
×
78
                }
79
            }
80

NEW
81
            if ($files['module']) {
×
NEW
82
                $moduleConfig = include $base . 'module.php';
×
83

84
                // Регистрация моделей и их возможностей
85
                foreach ($moduleConfig['models'] ?? [] as $model => $config) {
×
86
                    /** @var class-string $model */
87
                    $morphName = $model::$morphName;
×
88
                    Relation::morphMap([$morphName => $model]);
×
89

90
                    if ($search = $config['search'] ?? null) {
×
91
                        Registry::search($model, $search['view'], $search['with'] ?? []);
×
92
                    }
93

94
                    if ($feed = $config['feed'] ?? null) {
×
95
                        Registry::feed($model, $feed['withs'], $feed['view']);
×
96
                    }
97

98
                    match ($config['upload'] ?? null) {
×
99
                        'media' => Registry::mediaType($morphName),
×
100
                        'file'  => Registry::fileType($morphName),
×
101
                        default => null,
×
102
                    };
×
103

104
                    if (! empty($config['rating'])) {
×
105
                        Registry::ratingType($morphName);
×
106
                    }
107

108
                    if ($label = $config['label'] ?? null) {
×
109
                        Registry::label($morphName, $label);
×
110
                    }
111

112
                    if (! empty($config['spam'])) {
×
113
                        Registry::spam($morphName, Registry::$labelTypes[$morphName] ?? $morphName);
×
114
                    }
115
                }
116

117
                // Регистрация наблюдателей
118
                foreach ($moduleConfig['observers'] ?? [] as $modelClass => $observerClass) {
×
119
                    $modelClass::observe($observerClass);
×
120
                }
121

122
                // Регистрация консольных команд
NEW
123
                if (isset($moduleConfig['schedule']) && $this->app->runningInConsole()) {
×
124
                    $this->app->booted(function () use ($moduleConfig) {
×
125
                        $moduleConfig['schedule']($this->app->make(Schedule::class));
×
126
                    });
×
127
                }
128

129
                // Регистрация пересчётов
130
                foreach ($moduleConfig['restatement'] ?? [] as $key => $callback) {
×
131
                    Restatement::register($key, $callback);
×
132
                }
133
            }
134

NEW
135
            if (! empty($files['commands']) && $this->app->runningInConsole()) {
×
NEW
136
                $this->commands($files['commands']);
×
137
            }
138
        }
139
    }
140
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc