diff options
author | Thomas Lange <code@nerdmind.de> | 2018-12-31 00:23:06 +0100 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2018-12-31 00:23:06 +0100 |
commit | a0725d0bf159283e278168e3bd1dc0fe3e6da7ab (patch) | |
tree | a7788e618b82c7957cc56e2be3967fcfa8f03df0 /include/classes/Document.php | |
parent | df4865e7bcc3857be2f4b57d565a501a097b0daa (diff) | |
download | bigpipe-a0725d0bf159283e278168e3bd1dc0fe3e6da7ab.tar.gz bigpipe-a0725d0bf159283e278168e3bd1dc0fe3e6da7ab.tar.xz bigpipe-a0725d0bf159283e278168e3bd1dc0fe3e6da7ab.zip |
Temporary branch: last-pagelet-event-optimizationlast-pagelet-event-optimization
Diffstat (limited to 'include/classes/Document.php')
-rw-r--r-- | include/classes/Document.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/include/classes/Document.php b/include/classes/Document.php new file mode 100644 index 0000000..9b9893a --- /dev/null +++ b/include/classes/Document.php @@ -0,0 +1,34 @@ +<?php +use BigPipe\BigPipe; +use BigPipe\Pagelet; + +class Document { + private $contentCallbacks = []; + private $pagelets = []; + + public function addPagelet(Pagelet $Pagelet, callable $callback) { + $this->pagelets[] = $Pagelet; + + $this->contentCallbacks[$Pagelet->getID()] = $callback; + + if(!BigPipe::enabled()) { + $Pagelet->addHTML($callback($Pagelet)); + } + } + + public function render($content_html, $sidebar_html) { + require 'template/document.php'; + BigPipe::flushOutputBuffer(); + + if(BigPipe::enabled()) { + foreach($this->pagelets as $Pagelet) { + $Pagelet->addHTML($this->contentCallbacks[$Pagelet->getID()]($Pagelet)); + $Pagelet->flush(); + } + } + + BigPipe::completeResponse(); + echo "</body>\n</html>"; + } +} +?>
\ No newline at end of file |