aboutsummaryrefslogtreecommitdiffstats
path: root/include/classes/BigPipe/BigPipe.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2018-01-21 10:53:59 +0100
committerThomas Lange <code@nerdmind.de>2018-01-21 10:53:59 +0100
commit313b4fbe8d2057e6672e0ea479753c5710e85404 (patch)
tree419c3cc60dbdb38e3b336a26d7bb4870ab92ddec /include/classes/BigPipe/BigPipe.php
parent7d9b548391780db5d590a7148411b6eb59c189fb (diff)
downloadbigpipe-313b4fbe8d2057e6672e0ea479753c5710e85404.tar.gz
bigpipe-313b4fbe8d2057e6672e0ea479753c5710e85404.tar.xz
bigpipe-313b4fbe8d2057e6672e0ea479753c5710e85404.zip
Restructure the BigPipe::render() method
Diffstat (limited to 'include/classes/BigPipe/BigPipe.php')
-rw-r--r--include/classes/BigPipe/BigPipe.php24
1 files changed, 14 insertions, 10 deletions
diff --git a/include/classes/BigPipe/BigPipe.php b/include/classes/BigPipe/BigPipe.php
index 6e4c7f4..b94a6ae 100644
--- a/include/classes/BigPipe/BigPipe.php
+++ b/include/classes/BigPipe/BigPipe.php
@@ -67,8 +67,6 @@ class BigPipe {
public static function render() {
self::flushOutputBuffer();
- $i = 0;
-
$pagelets_ordered = [];
foreach(self::$pagelets as $Pagelet) {
@@ -80,8 +78,19 @@ class BigPipe {
if(!empty($pagelets_ordered)) {
$pagelets = call_user_func_array('array_merge', $pagelets_ordered);
- foreach($pagelets as $Pagelet) {
- if(!self::enabled()) {
+ if(self::enabled()) {
+ foreach($pagelets as $Pagelet) {
+ self::singleResponse($Pagelet);
+ self::flushOutputBuffer();
+ }
+ }
+
+ # NOTE: If BigPipe is disabled, Pagelet::flush() will NOT call BigPipe::dequeue().
+ # This means that (if the pipeline is disabled) $pagelets_ordered contains ALL
+ # Pagelets regardless of whether if Pagelet::flush() was already called. And then
+ # we can iterate over them and echo all requiered CSS and JS resources.
+ else {
+ foreach($pagelets as $Pagelet) {
foreach($Pagelet->getResources()[Resource::TYPE_STYLESHEET] as $Resource) {
echo "{$Resource->renderHTML()}\n";
}
@@ -94,15 +103,10 @@ class BigPipe {
echo "<script>{$JSCode}</script>\n";
}
}
-
- else {
- self::singleResponse($Pagelet);
- self::flushOutputBuffer();
- }
}
}
- if(BigPipe::enabled()) {
+ if(self::enabled()) {
echo "<script>BigPipe.onLastPageletArrived();</script>\n";
}
}