Skip to content

Commit

Permalink
CoreMacros: {status} uses http_response_code() related to nette/http#113
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 19, 2016
1 parent 6c37116 commit a591038
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Latte/Macros/CoreMacros.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public function macroStatus(MacroNode $node, PhpWriter $writer)
throw new CompileException('Modifiers are not allowed in ' . $node->getNotation());
}
return $writer->write((substr($node->args, -1) === '?' ? 'if (!headers_sent()) ' : '') .
'header((isset($_SERVER["SERVER_PROTOCOL"]) ? $_SERVER["SERVER_PROTOCOL"] : "HTTP/1.1") . " " . %0.var, TRUE, %0.var);', (int) $node->args
'http_response_code(%0.var);', (int) $node->args
);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Latte/CoreMacros.status.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ $latte = new Latte\Engine;
$latte->setLoader(new Latte\Loaders\StringLoader);

Assert::match(
'%A%header((isset($_SERVER["SERVER_PROTOCOL"]) ? $_SERVER["SERVER_PROTOCOL"] : "HTTP/1.1") . " " . 200, TRUE, 200)%A%',
'%A%http_response_code(200)%A%',
@$latte->compile('{status 200}') // @ macro is deprecated
);

Assert::match(
'%A%if (!headers_sent()) header((isset($_SERVER["SERVER_PROTOCOL"]) ? $_SERVER["SERVER_PROTOCOL"] : "HTTP/1.1") . " " . 300, TRUE, 300)%A%',
'%A%if (!headers_sent()) http_response_code(300)%A%',
@$latte->compile('{status 300?}')
);

0 comments on commit a591038

Please sign in to comment.