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

visavi / rotor / 27440345661

12 Jun 2026 08:11PM UTC coverage: 16.687% (+0.04%) from 16.644%
27440345661

push

github

visavi
Упростил Registry модулей, поправил метки в жалобах, улучшил подсветку комментария при переходе по якорю, улучшил отправку жалобы

6 of 41 new or added lines in 7 files covered. (14.63%)

2 existing lines in 2 files now uncovered.

960 of 5753 relevant lines covered (16.69%)

2.36 hits per line

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

8.62
/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
108✔
21
    {
22
        //
23
    }
108✔
24

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

32
        foreach ($modules as $module => $data) {
108✔
33
            $base = base_path('modules/' . $module);
×
34

35
            // чтобы не падать на include отсутствующих файлов из устаревшего кэша
36
            if (! is_dir($base)) {
×
37
                continue;
×
38
            }
39

40
            $files = $data['files'] ?? [];
×
41
            $moduleKey = Str::snake($module);
×
42

43
            if ($files['views'] ?? false) {
×
44
                $this->loadViewsFrom($base . '/resources/views', $moduleKey);
×
45
            }
46

47
            if ($files['lang'] ?? false) {
×
48
                $this->loadTranslationsFrom($base . '/resources/lang', $moduleKey);
×
49
            }
50

51
            if ($files['helpers'] ?? false) {
×
52
                include_once $base . '/helpers.php';
×
53
            }
54

55
            if ($files['hooks'] ?? false) {
×
56
                include_once $base . '/hooks.php';
×
57
            }
58

59
            if ($files['routes'] ?? false) {
×
60
                $this->loadRoutesFrom($base . '/routes.php');
×
61
            }
62

63
            if ($data['config'] ?? false) {
×
64
                Config::set($moduleKey, $data['config']);
×
65
            }
66

67
            if ($files['middleware'] ?? false) {
×
68
                $middleware = include $base . '/middleware.php';
×
69

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

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

79
            if ($files['module'] ?? false) {
×
80
                $moduleConfig = include $base . '/module.php';
×
81

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

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

92
                    if ($feed = $config['feed'] ?? null) {
×
93
                        Registry::feed($model, $feed);
×
94
                    }
95

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

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

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

110
                    if (! empty($config['spam'])) {
×
NEW
111
                        Registry::spamType($morphName);
×
112
                    }
113
                }
114

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

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

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

133
            if (! empty($files['commands']) && $this->app->runningInConsole()) {
×
134
                $this->commands($files['commands']);
×
135
            }
136
        }
137
    }
138
}
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