1 | <?php |
||
2 | |||
3 | namespace Yansongda\LaravelParsehtml; |
||
4 | |||
5 | use Illuminate\Foundation\Application as LaravelApplication; |
||
6 | use Illuminate\Support\Facades\Blade; |
||
7 | use Illuminate\Support\ServiceProvider; |
||
8 | use Laravel\Lumen\Application as LumenApplication; |
||
9 | use League\HTMLToMarkdown\HtmlConverter; |
||
10 | |||
11 | class ParsehtmlServiceProvider extends ServiceProvider |
||
12 | { |
||
13 | /** |
||
14 | * delay to load service. |
||
15 | * |
||
16 | * @var bool |
||
17 | */ |
||
18 | protected $defer = true; |
||
19 | |||
20 | /** |
||
21 | * boot a service. |
||
22 | * |
||
23 | * @author yansongda <[email protected]> |
||
24 | * |
||
25 | * @return void |
||
26 | */ |
||
27 | public function boot() |
||
28 | { |
||
29 | if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) { |
||
30 | $this->publishes([ |
||
31 | dirname(__DIR__).'/config/markdown.php' => config_path('markdown.php'), |
||
32 | ], 'laravel-html-config'); |
||
33 | } elseif ($this->app instanceof LumenApplication) { |
||
34 | $this->app->configure('markdown'); |
||
35 | } |
||
36 | |||
37 | Blade::directive('parsehtml', function ($expression) { |
||
38 | return "<?php echo parsehtml($expression); ?>"; |
||
39 | }); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * registe the service. |
||
44 | * |
||
45 | * @return void |
||
46 | */ |
||
47 | public function register() |
||
48 | { |
||
49 | $this->mergeConfigFrom(dirname(__DIR__).'/config/markdown.php', 'markdown'); |
||
50 | |||
51 | $this->app->singleton(HtmlConverter::class, function ($app) { |
||
0 ignored issues
–
show
|
|||
52 | return new HtmlConverter(config('markdown.parsehtml')); |
||
53 | }); |
||
54 | |||
55 | $this->app->alias(HtmlConverter::class, 'parsehtml'); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * providers. |
||
60 | * |
||
61 | * @return array |
||
62 | */ |
||
63 | public function provides() |
||
64 | { |
||
65 | return [HtmlConverter::class, 'parsehtml']; |
||
66 | } |
||
67 | } |
||
68 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.