N°7314 - Add Symfony Response alternative to Webpage::output()

This commit is contained in:
Molkobain
2024-01-17 20:35:11 +01:00
parent 646e86b207
commit 9fa53d43ab
2 changed files with 87 additions and 27 deletions

View File

@@ -829,6 +829,31 @@ HTML;
* @throws \Exception
*/
public function output()
{
// Send headers
if ($this->GetOutputFormat() === 'html') {
foreach ($this->a_headers as $sHeader) {
header($sHeader);
}
}
// Render HTKL content
$sHtml = $this->RenderContent();
// Echo global HTML
$oKpi = new ExecutionKPI();
echo $sHtml;
$oKpi->ComputeAndReport('Echoing ('.round(strlen($sHtml) / 1024).' Kb)');
DBSearch::RecordQueryTrace();
ExecutionKPI::ReportStats();
}
/**
* @inheritDoc
* @since 3.2.0 N°6935
*/
protected function RenderContent(): string
{
$oKpi = new ExecutionKPI();
@@ -933,16 +958,16 @@ HTML;
$aData['aDeferredBlocks']['oPageContent'] = $this->GetDeferredBlocks($this->GetContentLayout());
// - Prepare generic templates
$aData['aTemplates'] = array();
// TODO 3.1 Replace hardcoded 'Please wait' with dict entries
// - Modal template with loader
$oModalTemplateContentBlock = new UIContentBlock();
$oModalTemplateContentBlock->AddCSSClass('ibo-modal')
->AddDataAttribute('role', 'ibo-modal')
->AddSubBlock(SpinnerUIBlockFactory::MakeMedium(null, 'Please wait'));
$aData['aTemplates'][] = TemplateUIBlockFactory::MakeForBlock('ibo-modal-template', $oModalTemplateContentBlock);
// - Small loader template
$oSmallLoaderTemplateContentBlock = new UIContentBlock();
$oSmallLoaderTemplateContentBlock->AddSubBlock(SpinnerUIBlockFactory::MakeSmall(null , 'Please wait'));
@@ -997,27 +1022,14 @@ HTML;
$oTwigEnv = TwigHelper::GetTwigEnvironment(BlockRenderer::TWIG_BASE_PATH, BlockRenderer::TWIG_ADDITIONAL_PATHS);
// Send headers
if ($this->GetOutputFormat() === 'html') {
foreach ($this->a_headers as $sHeader) {
header($sHeader);
}
}
// Render final TWIG into global HTML
$sHtml = TwigHelper::RenderTemplate($oTwigEnv, $aData, $this->GetTemplateRelPath());
$oKpi->ComputeAndReport(get_class($this).' output');
// Echo global HTML
echo $sHtml;
$oKpi->ComputeAndReport('Echoing ('.round(strlen($sHtml) / 1024).' Kb)');
$oKpi->ComputeAndReport("Rendering content (".static::class.")");
DBSearch::RecordQueryTrace();
ExecutionKPI::ReportStats();
return $sHtml;
}
/**
* @inheritDoc
* @throws \Exception