1
1
<?php
2
2
3
- class WhitespaceSuppressorRequestProcessor extends RequestProcessor {
3
+ class WhitespaceSuppressorRequestProcessor extends RequestProcessor
4
+ {
4
5
5
- // false or 'none' - disable processing
6
- // 'always' - enable processing in all environments
7
- // 'live-only' - enable processing only on live environment
8
- private static $ suppress = 'live-only ' ; // set to false or 'none' to disable processing
6
+ // false or 'none' - disable processing
7
+ // 'always' - enable processing in all environments
8
+ // 'live-only' - enable processing only on live environment
9
+ private static $ suppress = 'live-only ' ; // set to false or 'none' to disable processing
9
10
10
11
11
- public function postRequest (SS_HTTPRequest $ request , SS_HTTPResponse $ response , DataModel $ model ) {
12
- if (preg_match ('/text\/html/ ' , $ response ->getHeader ('Content-Type ' ))) {
13
- $ response ->setBody (
14
- $ this ->SuppressWhitespace ($ response ->getBody ())
15
- );
16
- }
17
- }
12
+ public function postRequest (SS_HTTPRequest $ request , SS_HTTPResponse $ response , DataModel $ model )
13
+ {
14
+ if (preg_match ('/text\/html/ ' , $ response ->getHeader ('Content-Type ' ))) {
15
+ $ response ->setBody (
16
+ $ this ->SuppressWhitespace ($ response ->getBody ())
17
+ );
18
+ }
19
+ }
18
20
19
- public function SuppressWhitespace ($ html ) {
20
- if ( $ this -> config ()-> suppress == ' always ' || ( $ this -> config ()-> suppress == ' live-only ' && Director:: isLive ())) {
21
- $ html = preg_replace ( " /\s+/ " , ' ' , trim ( $ html ));
22
- $ html = str_replace ( array ( ' <!-- --> ' , ' //<![CDATA[ ' , '//]]> ' ), '' , $ html );
23
- // TODO: remove all comments?
24
- }
25
- return $ html ;
26
- }
27
-
28
- }
21
+ public function SuppressWhitespace ($ html )
22
+ {
23
+ if ( $ this -> config ()-> suppress == ' always ' || ( $ this -> config ()-> suppress == ' live-only ' && Director:: isLive ())) {
24
+ $ html = preg_replace ( " /\s+/ " , ' ' , trim ( $ html) );
25
+ $ html = str_replace ( array ( ' <!-- --> ' , ' //<![CDATA[ ' , ' //]]> ' ), '' , $ html );
26
+ // TODO: remove all comments?
27
+ }
28
+ return $ html ;
29
+ }
30
+ }
0 commit comments