|
1 | 1 | <?php
|
2 | 2 |
|
3 |
| -namespace App\Providers; |
| 3 | +namespace Saritasa\Laravel\Controllers\Providers; |
4 | 4 |
|
5 | 5 | use Html;
|
6 |
| -use Illuminate\Support\Facades\Config; |
7 | 6 | use Illuminate\Support\ServiceProvider;
|
8 | 7 |
|
9 | 8 | class MacroServiceProvider extends ServiceProvider
|
10 | 9 | {
|
11 |
| - |
12 | 10 | public function boot()
|
13 | 11 | {
|
| 12 | + $this->registerScriptLinkMacro(); |
| 13 | + $this->registerStyleLinkMacro(); |
| 14 | + } |
14 | 15 |
|
15 |
| - // Html macro for generate html tag for include javascript file |
16 |
| - // example of usage: {!! HTML::scriptLink('/assets/js/bower.js') !!} |
17 |
| - HTML::macro('scriptLink', function($src, $hasMinified = true, $hasVersioning = true) |
18 |
| - { |
19 |
| - $revisions = Config::get('revision.files'); |
| 16 | + /** |
| 17 | + * Register any application services. |
| 18 | + * |
| 19 | + * @return void |
| 20 | + */ |
| 21 | + public function register() |
| 22 | + { |
| 23 | + } |
20 | 24 |
|
21 |
| - if ($hasMinified && !Config::get('app.debug')) { |
| 25 | + /** |
| 26 | + * Html macro for generate html tag for include javascript file |
| 27 | + * example of usage: {!! HTML::scriptLink('/assets/js/bower.js') !!} |
| 28 | + */ |
| 29 | + public function registerScriptLinkMacro() |
| 30 | + { |
| 31 | + HTML::macro('scriptLink', function ($src, $hasMinified = true, $hasVersioning = true) { |
| 32 | + $revisions = config('revision.files'); |
| 33 | + |
| 34 | + if ($hasMinified && !config('app.debug')) { |
22 | 35 | $src = str_replace('.js', '.min.js', $src);
|
23 | 36 | }
|
24 | 37 | if ($hasVersioning) {
|
25 |
| - $src .= (isset($revisions[ltrim($src, '/')]) ? '?'.$revisions[ltrim($src, '/')] : ''); |
| 38 | + $src .= (isset($revisions[ltrim($src, '/')]) ? '?' . $revisions[ltrim($src, '/')] : ''); |
26 | 39 | }
|
27 | 40 | return "<script src=\"$src\"></script>";
|
28 | 41 | });
|
| 42 | + } |
29 | 43 |
|
30 |
| - // Html macro for generate html tag for include css file |
31 |
| - // example of usage: {!! HTML::styleLink('/assets/css/bower.css') !!} |
32 |
| - HTML::macro('styleLink', function($href, $hasMinified = true, $hasVersioning = true) |
33 |
| - { |
34 |
| - $revisions = Config::get('revision.files'); |
| 44 | + /** |
| 45 | + * Html macro for generate html tag for include css file |
| 46 | + * example of usage: {!! HTML::styleLink('/assets/css/bower.css') !!} |
| 47 | + */ |
| 48 | + public function registerStyleLinkMacro() |
| 49 | + { |
| 50 | + HTML::macro('styleLink', function ($href, $hasMinified = true, $hasVersioning = true) { |
| 51 | + $revisions = config('revision.files'); |
35 | 52 |
|
36 |
| - if ($hasMinified && !Config::get('app.debug')) { |
| 53 | + if ($hasMinified && !config('app.debug')) { |
37 | 54 | $href = str_replace('.css', '.min.css', $href);
|
38 | 55 | }
|
39 | 56 | if ($hasVersioning) {
|
40 |
| - $href .= (isset($revisions[ltrim($href, '/')]) ? '?'.$revisions[ltrim($href, '/')] : ''); |
| 57 | + $href .= (isset($revisions[ltrim($href, '/')]) ? '?' . $revisions[ltrim($href, '/')] : ''); |
41 | 58 | }
|
42 | 59 | return "<link rel=\"stylesheet\" href=\"$href\">";
|
43 | 60 | });
|
44 |
| - |
45 |
| - |
46 |
| - } |
47 |
| - |
48 |
| - /** |
49 |
| - * Register any application services. |
50 |
| - * |
51 |
| - * @return void |
52 |
| - */ |
53 |
| - public function register() |
54 |
| - { |
55 |
| - |
56 | 61 | }
|
57 | 62 | }
|
0 commit comments