File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 11<?php
2+
23namespace BeyondCode \QueryDetector \Outputs ;
4+
35use Illuminate \Support \Collection ;
46use Symfony \Component \HttpFoundation \Response ;
57
@@ -10,18 +12,25 @@ public function output(Collection $detectedQueries, Response $response)
1012 if ($ response ->isRedirection ()) {
1113 return ;
1214 }
15+
1316 $ content = $ response ->getContent ();
17+
1418 $ outputContent = $ this ->getOutputContent ($ detectedQueries );
19+
1520 $ pos = strripos ($ content , '</body> ' );
21+
1622 if (false !== $ pos ) {
1723 $ content = substr ($ content , 0 , $ pos ) . $ outputContent . substr ($ content , $ pos );
1824 } else {
1925 $ content = $ content . $ outputContent ;
2026 }
27+
2128 // Update the new content and reset the content length
2229 $ response ->setContent ($ content );
30+
2331 $ response ->headers ->remove ('Content-Length ' );
2432 }
33+
2534 protected function getOutputContent (Collection $ detectedQueries )
2635 {
2736 $ output = '<script type="text/javascript"> ' ;
@@ -33,6 +42,7 @@ protected function getOutputContent(Collection $detectedQueries)
3342 }
3443 $ output .= "') " ;
3544 $ output .= '</script> ' ;
45+
3646 return $ output ;
3747 }
3848}
You can’t perform that action at this time.
0 commit comments