Skip to content

Commit

Permalink
Adjust code after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Krzeszowiak committed Apr 8, 2020
1 parent 4fa5447 commit 08f2bd4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/code/Magento/Theme/Controller/Result/JsFooterPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,19 @@ public function __construct(ScopeConfigInterface $scopeConfig)
*/
public function beforeSendResponse(Http $subject)
{
$content = $subject->getContent() ?? '';
$content = (string)$subject->getContent();

$bodyClose = '</body';

if (is_string($content) && strpos($content, $bodyClose) !== false && $this->scopeConfig->isSetFlag(
if (strpos($content, $bodyClose) !== false && $this->scopeConfig->isSetFlag(
self::XML_PATH_DEV_MOVE_JS_TO_BOTTOM,
ScopeInterface::SCOPE_STORE
)) {
$scripts = '';

$scriptOpen = '<script';
$scriptClose = '</script>';

$scriptOpenPos = strpos($content, $scriptOpen);

while ($scriptOpenPos !== false) {
$scriptClosePos = strpos($content, $scriptClose, $scriptOpenPos);
$script = substr($content, $scriptOpenPos, $scriptClosePos - $scriptOpenPos + strlen($scriptClose));
Expand Down

0 comments on commit 08f2bd4

Please sign in to comment.