File tree Expand file tree Collapse file tree 2 files changed +8
-11
lines changed
Expand file tree Collapse file tree 2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change 11<?php
22
3- namespace Thoughtco \Minify \Listeners ;
3+ namespace Thoughtco \Minify \Middleware ;
44
5+ use Closure ;
56use File ;
67use MatthiasMullie \Minify ;
7- use Statamic \Events \ResponseCreated ;
88
9- class MinifyListener
9+ class MinifyMiddleware
1010{
11-
1211 private $ minPath = 'min/ ' ;
1312
1413 /**
1514 * before response sent back to browser
1615 */
17- public function handle (ResponseCreated $ event )
16+ public function handle ($ request , Closure $ next )
1817 {
1918 $ content = $ event ->response ->content ();
2019 if (stripos ($ content , '<html ' ) !== false )
Original file line number Diff line number Diff line change 22
33namespace Thoughtco \Minify ;
44
5+ use Illuminate \Contracts \Http \;
56use Illuminate \Support \Facades \File ;
67use Statamic \Providers \AddonServiceProvider ;
78use Statamic \Statamic ;
9+ use Thoughtco \Minify \Middleware \MinifyMiddleware ;
810
911class ServiceProvider extends AddonServiceProvider
1012{
11- protected $ listen = [
12- 'Statamic\Events\ResponseCreated ' => [
13- 'Thoughtco\Minify\Listeners\MinifyListener ' ,
14- ],
15- ];
16-
1713 public function boot ()
1814 {
1915 parent ::boot ();
2016
17+ app (Kernel::class)->pushMiddleware (MinifyMiddleware::class);
18+
2119 Statamic::afterInstalled (function ($ command ) {
2220
2321 if (File::exists (config_path ('thoughtco/minify.php ' )))
You can’t perform that action at this time.
0 commit comments