File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
lib/internal/Magento/Framework/View Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,18 @@ public function minify($file)
114
114
{
115
115
$ dir = dirname ($ file );
116
116
$ fileName = basename ($ file );
117
+ $ content = $ this ->readFactory ->create ($ dir )->readFile ($ fileName );
118
+ //Storing Heredocs
119
+ $ heredocs = [];
120
+ $ content = preg_replace_callback (
121
+ '/<<<([A-z]+).*?\1;/ims ' ,
122
+ function ($ match ) use (&$ heredocs ) {
123
+ $ heredocs [] = $ match [0 ];
124
+
125
+ return '__MINIFIED_HEREDOC__ ' .(count ($ heredocs ) - 1 );
126
+ },
127
+ $ content
128
+ );
117
129
$ content = preg_replace (
118
130
'#(?<!]]>)\s+</# ' ,
119
131
'</ ' ,
@@ -136,7 +148,7 @@ public function minify($file)
136
148
preg_replace (
137
149
'#(?<!:)//[^\n\r]*(\<\?php)[^\n\r]*(\s\?\>)[^\n\r]*# ' ,
138
150
'' ,
139
- $ this -> readFactory -> create ( $ dir )-> readFile ( $ fileName )
151
+ $ content
140
152
)
141
153
)
142
154
)
@@ -145,6 +157,15 @@ public function minify($file)
145
157
)
146
158
);
147
159
160
+ //Restoring Heredocs
161
+ $ content = preg_replace_callback (
162
+ '/__MINIFIED_HEREDOC__(\d+)/ims ' ,
163
+ function ($ match ) use ($ heredocs ) {
164
+ return $ heredocs [(int )$ match [1 ]];
165
+ },
166
+ $ content
167
+ );
168
+
148
169
if (!$ this ->htmlDirectory ->isExist ()) {
149
170
$ this ->htmlDirectory ->create ();
150
171
}
Original file line number Diff line number Diff line change @@ -167,6 +167,12 @@ public function testMinify()
167
167
<?php // echo \$block->getChildHtml('anotherChildBlock'); ?>
168
168
<?php // endif; ?>
169
169
</body>
170
+ <?php
171
+ \$sometext = <<<SOMETEXT
172
+ mytext
173
+ mytextline2
174
+ SOMETEXT;
175
+ ?>
170
176
</html>
171
177
TEXT ;
172
178
@@ -189,7 +195,10 @@ public function testMinify()
189
195
}
190
196
});
191
197
//]]>
192
- </script><?php echo "http://some.link.com/" ?> <?php echo "//some.link.com/" ?> <?php echo '//some.link.com/' ?> <em>inline text</em> <a href="http://www.<?php echo 'hi' ?>"></a> <?php ?> <?php echo \$block->getChildHtml('someChildBlock'); ?> <?php ?> <?php ?> <?php ?></body></html>
198
+ </script><?php echo "http://some.link.com/" ?> <?php echo "//some.link.com/" ?> <?php echo '//some.link.com/' ?> <em>inline text</em> <a href="http://www.<?php echo 'hi' ?>"></a> <?php ?> <?php echo \$block->getChildHtml('someChildBlock'); ?> <?php ?> <?php ?> <?php ?></body><?php \$sometext = <<<SOMETEXT
199
+ mytext
200
+ mytextline2
201
+ SOMETEXT; ?></html>
193
202
TEXT ;
194
203
195
204
$ this ->appDirectoryMock ->expects ($ this ->once ())
You can’t perform that action at this time.
0 commit comments