aboutsummaryrefslogtreecommitdiffstats
path: root/include/classes
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2018-01-21 11:01:08 +0100
committerThomas Lange <code@nerdmind.de>2018-01-21 11:01:08 +0100
commitda4f78acb9b9d932423bf59a791554cf9552381b (patch)
tree0cd4a9c8313c75cdb9a6b3aafa941dabc22761d8 /include/classes
parentad58f8bbc662e6714740163de3794b8e36b11cfc (diff)
downloadbigpipe-da4f78acb9b9d932423bf59a791554cf9552381b.tar.gz
bigpipe-da4f78acb9b9d932423bf59a791554cf9552381b.tar.xz
bigpipe-da4f78acb9b9d932423bf59a791554cf9552381b.zip
Move BigPipe::singleResponse() to Pagelet::flush()
Diffstat (limited to 'include/classes')
-rw-r--r--include/classes/BigPipe/BigPipe.php18
-rw-r--r--include/classes/BigPipe/Pagelet.php18
2 files changed, 19 insertions, 17 deletions
diff --git a/include/classes/BigPipe/BigPipe.php b/include/classes/BigPipe/BigPipe.php
index 9bb9fcb..d84083e 100644
--- a/include/classes/BigPipe/BigPipe.php
+++ b/include/classes/BigPipe/BigPipe.php
@@ -40,21 +40,6 @@ class BigPipe {
}
#===============================================================================
- # Prints a single pagelet response
- #===============================================================================
- private static function singleResponse(Pagelet $Pagelet) {
- $pageletJSON = $Pagelet->getStructure();
-
- $pageletHTML = removeLineBreaksAndTabs($Pagelet->getHTML());
- $pageletHTML = str_replace('--', '&#45;&#45;', $pageletHTML);
-
- $pageletJSON = json_encode($pageletJSON);
-
- echo "<code hidden id=\"_{$Pagelet->getID()}\"><!-- {$pageletHTML} --></code>\n";
- echo "<script>BigPipe.onPageletArrive({$pageletJSON}, document.getElementById(\"_{$Pagelet->getID()}\"));</script>\n\n";
- }
-
- #===============================================================================
# Sends output buffer so far as possible towards user
#===============================================================================
public static function flushOutputBuffer() {
@@ -80,8 +65,7 @@ class BigPipe {
if(self::enabled()) {
foreach($pagelets as $Pagelet) {
- self::singleResponse($Pagelet);
- self::flushOutputBuffer();
+ $Pagelet->flush();
}
}
diff --git a/include/classes/BigPipe/Pagelet.php b/include/classes/BigPipe/Pagelet.php
index ae465ab..101ec34 100644
--- a/include/classes/BigPipe/Pagelet.php
+++ b/include/classes/BigPipe/Pagelet.php
@@ -148,6 +148,24 @@ class Pagelet extends Item {
}
#===============================================================================
+ # Flush pagelet immediately
+ #===============================================================================
+ public function flush() {
+ if(BigPipe::enabled()) {
+ $pageletHTML = removeLineBreaksAndTabs($this->getHTML());
+ $pageletHTML = str_replace('--', '&#45;&#45;', $pageletHTML);
+
+ $pageletJSON = json_encode($this->getStructure());
+
+ echo "<code hidden id=\"_{$this->getID()}\"><!-- {$pageletHTML} --></code>\n";
+ echo "<script>BigPipe.onPageletArrive({$pageletJSON}, document.getElementById(\"_{$this->getID()}\"));</script>\n\n";
+
+ BigPipe::dequeue($this);
+ BigPipe::flushOutputBuffer();
+ }
+ }
+
+ #===============================================================================
# Magic method: __toString()
#===============================================================================
public function __toString() {