16
16
17
17
namespace GrahamCampbell \HTMLMin ;
18
18
19
+ use Illuminate \Contracts \Foundation \Application ;
19
20
use Illuminate \Support \ServiceProvider ;
20
21
use Illuminate \View \Engines \CompilerEngine ;
21
22
@@ -44,14 +45,12 @@ public function boot()
44
45
{
45
46
$ this ->package ('graham-campbell/htmlmin ' , 'graham-campbell/htmlmin ' , __DIR__ );
46
47
47
- // setup blade optimisations if enabled
48
48
if ($ this ->app ['config ' ]['graham-campbell/htmlmin::blade ' ]) {
49
- $ this ->enableBladeOptimisations ();
49
+ $ this ->enableBladeOptimisations ($ this -> app );
50
50
}
51
51
52
- // setup live optimisations if enabled
53
52
if ($ this ->app ['config ' ]['graham-campbell/htmlmin::live ' ]) {
54
- $ this ->enableLiveOptimisations ();
53
+ $ this ->enableLiveOptimisations ($ this -> app );
55
54
}
56
55
57
56
$ this ->setupFilters ();
@@ -60,33 +59,30 @@ public function boot()
60
59
/**
61
60
* Enable blade optimisations.
62
61
*
62
+ * @param \Illuminate\Contracts\Foundation\Application $app
63
+ *
63
64
* @return void
64
65
*/
65
- protected function enableBladeOptimisations ()
66
+ protected function enableBladeOptimisations (Application $ app )
66
67
{
67
- $ app = $ this ->app ;
68
-
69
- // register a new engine
70
68
$ app ['view ' ]->getEngineResolver ()->register ('blade ' , function () use ($ app ) {
71
69
$ compiler = $ app ['htmlmin.compiler ' ];
72
70
73
71
return new CompilerEngine ($ compiler );
74
72
});
75
73
76
- // add the extension
77
74
$ app ->view ->addExtension ('blade.php ' , 'blade ' );
78
75
}
79
76
80
77
/**
81
78
* Enable live optimisations.
82
79
*
80
+ * @param \Illuminate\Contracts\Foundation\Application $app
81
+ *
83
82
* @return void
84
83
*/
85
- protected function enableLiveOptimisations ()
84
+ protected function enableLiveOptimisations (Application $ app )
86
85
{
87
- $ app = $ this ->app ;
88
-
89
- // register a new filter
90
86
$ app ['router ' ]->after (function ($ request , $ response ) use ($ app ) {
91
87
$ app ['htmlmin ' ]->live ($ response );
92
88
});
0 commit comments