Total Complexity | 5 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class DynamicUnitServiceProvider extends ServiceProvider |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * Bootstrap services. |
||
14 | */ |
||
15 | public function boot(): void |
||
16 | { |
||
17 | $this->bootConfig(); |
||
18 | $this->loadFacades(); |
||
19 | $this->bindMacroService(); |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * 修改query |
||
24 | * |
||
25 | * @author Dennis Lui <[email protected]> |
||
26 | * @return void |
||
27 | */ |
||
28 | protected function bindMacroService(): void |
||
29 | { |
||
30 | if (class_exists(SimpleService::class)) { |
||
31 | SimpleService::macro('queryAttribute', function (SimpleService $service, array $parameters) { |
||
32 | $attributeService = new DynamicAttributeService; |
||
33 | return $attributeService->queryAttribute($service,$parameters); |
||
34 | }); |
||
35 | } |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * 绑定Facades |
||
40 | * |
||
41 | * @author Dennis Lui <[email protected]> |
||
42 | * @return void |
||
43 | */ |
||
44 | protected function loadFacades(): void |
||
45 | { |
||
46 | $this->app->bind('dynamic_unit', fn() => new \SimpleCMS\DynamicUnit\Packages\DynamicUnit); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * 初始化配置文件 |
||
51 | * @return void |
||
52 | */ |
||
53 | protected function bootConfig(): void |
||
58 | } |
||
59 | } |
||
60 |