Files
spl-tools/pledge-update/page_renderer.php
2024-09-21 16:53:24 +10:00

29 lines
735 B
PHP

<?php
class SPLPageRenderer {
public function renderPledgePage($councils, $candidates) {
ob_start();
$didError = false;
set_error_handler(function($errno, $errstr, $errfile, $errline) use(&$didError) {
$didError = true;
error_log("Error: $errstr in $errfile on line $errline");
return true; // Prevent default error handling
});
require "template.php";
restore_error_handler();
$content = ob_get_clean();
// Explictly return null if we didn't generate any content or if there was an error
if (!empty($content) && !$didError) {
return $content;
} else {
return null;
}
}
}