|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Yansongda\LaravelParsedown; |
|
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 Parsedown; |
|
10
|
|
|
|
|
11
|
|
|
class ParsedownServiceProvider 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 |
|
30
|
|
|
&& $this->app->runningInConsole() |
|
31
|
|
|
) { |
|
32
|
|
|
$this->publishes( |
|
33
|
|
|
[ |
|
34
|
|
|
__DIR__.'/config/markdown.php' => config_path('markdown.php'), |
|
35
|
|
|
], |
|
36
|
|
|
'laravel-parsedown-config' |
|
37
|
|
|
); |
|
38
|
|
|
} elseif ($this->app instanceof LumenApplication) { |
|
39
|
|
|
$this->app->configure('markdown'); |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
Blade::directive('parsedown', function ($expression) { |
|
43
|
|
|
return "<?php echo parsedown($expression); ?>"; |
|
44
|
|
|
}); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* registe the service. |
|
49
|
|
|
* |
|
50
|
|
|
* @return void |
|
51
|
|
|
*/ |
|
52
|
|
|
public function register() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->mergeConfigFrom(dirname(__DIR__).'/config/markdown.php', 'markdown'); |
|
55
|
|
|
|
|
56
|
|
|
$this->app->singleton(Parsedown::class, function () { |
|
57
|
|
|
return Parsedown::instance()->setSafeMode(config('markdown.parsedown.safeMode')) |
|
58
|
|
|
->setBreaksEnabled(config('markdown.parsedown.breaksEnabled')) |
|
59
|
|
|
->setMarkupEscaped(config('markdown.parsedown.markupEscaped')) |
|
60
|
|
|
->setUrlsLinked(config('markdown.parsedown.urlsLinked')); |
|
61
|
|
|
}); |
|
62
|
|
|
|
|
63
|
|
|
$this->app->alias(Parsedown::class, 'parsedown'); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* providers. |
|
68
|
|
|
* |
|
69
|
|
|
* @return array |
|
70
|
|
|
*/ |
|
71
|
|
|
public function provides() |
|
72
|
|
|
{ |
|
73
|
|
|
return [Parsedown::class, 'parsedown']; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths