Warnings are now printed during codegen routine not registered to be invoked at shutdown
This commit is contained in:
parent
f557181341
commit
61c7ee7b35
|
@ -2,6 +2,8 @@
|
|||
namespace bhl_bind;
|
||||
use Exception;
|
||||
|
||||
$GLOBALS['BHL_BIND_WARNS'] = array();
|
||||
|
||||
function supported_tokens()
|
||||
{
|
||||
return [
|
||||
|
@ -48,7 +50,11 @@ function codegen(
|
|||
|
||||
$twig->addGlobal('plugins', $options['plugins']);
|
||||
|
||||
return $twig->render('codegen_autobind.twig', $options);
|
||||
$str = $twig->render('codegen_autobind.twig', $options);
|
||||
|
||||
print_warnings();
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
function get_twig(array $inc_path = [])
|
||||
|
@ -320,13 +326,19 @@ function add_twig_support(\Twig\Environment $twig)
|
|||
|
||||
function Warn($msg)
|
||||
{
|
||||
//NOTE: we can't just echo the value because it will
|
||||
// be rendered into resulting code
|
||||
register_shutdown_function(function() use($msg) {
|
||||
echo "BHL BIND WARN: $msg\n";
|
||||
});
|
||||
global $BHL_BIND_WARNS;
|
||||
$BHL_BIND_WARNS[] = $msg;
|
||||
}
|
||||
|
||||
function print_warnings()
|
||||
{
|
||||
global $BHL_BIND_WARNS;
|
||||
|
||||
foreach($BHL_BIND_WARNS as $msg)
|
||||
echo "BHL BIND WARN: $msg\n";
|
||||
}
|
||||
|
||||
|
||||
function paginate($total, $step)
|
||||
{
|
||||
//pages are returned as an array where each element is in interval [N, Y)
|
||||
|
|
Loading…
Reference in New Issue