diff options
Diffstat (limited to 'include/classes')
-rw-r--r-- | include/classes/BigPipe/BigPipe.php | 19 | ||||
-rw-r--r-- | include/classes/BigPipe/Pagelet.php | 4 |
2 files changed, 13 insertions, 10 deletions
diff --git a/include/classes/BigPipe/BigPipe.php b/include/classes/BigPipe/BigPipe.php index 30e3f41..6162388 100644 --- a/include/classes/BigPipe/BigPipe.php +++ b/include/classes/BigPipe/BigPipe.php @@ -15,17 +15,20 @@ class BigPipe { private static $pagelets = []; #=============================================================================== - # Enable or disable the pipeline mode + # Check if pipelining mode is enabled #=============================================================================== - public static function enabled($change = NULL) { - if($change !== NULL) { - self::$enabled = (bool) $change; - } - + public static function isEnabled(): bool { return self::$enabled; } #=============================================================================== + # Enable or disable the pipelining mode + #=============================================================================== + public static function setEnabled(bool $enabled): void { + self::$enabled = $enabled; + } + + #=============================================================================== # Insert pagelet into queue #=============================================================================== public static function enqueue(Pagelet $Pagelet) { @@ -63,7 +66,7 @@ class BigPipe { if(!empty($pagelets_ordered)) { $pagelets = call_user_func_array('array_merge', $pagelets_ordered); - if(self::enabled()) { + if(self::isEnabled()) { foreach($pagelets as $Pagelet) { $Pagelet->flush(); } @@ -90,7 +93,7 @@ class BigPipe { } } - if(self::enabled()) { + if(self::isEnabled()) { echo "<script>BigPipe.onLastPageletArrived();</script>\n"; } } diff --git a/include/classes/BigPipe/Pagelet.php b/include/classes/BigPipe/Pagelet.php index 0358df6..bd50c4b 100644 --- a/include/classes/BigPipe/Pagelet.php +++ b/include/classes/BigPipe/Pagelet.php @@ -150,7 +150,7 @@ class Pagelet extends Item { # Flush pagelet immediately #=============================================================================== public function flush() { - if(BigPipe::enabled()) { + if(BigPipe::isEnabled()) { $pageletHTML = str_replace(["\r", "\n", "\t"], '', $this->getHTML()); $pageletHTML = str_replace('--', '--', $pageletHTML); @@ -169,7 +169,7 @@ class Pagelet extends Item { #=============================================================================== public function __toString() { $pageletHTML = "<{$this->tagName} id=\"{$this->getID()}\">"; - $pageletHTML .= !BigPipe::enabled() ? $this->getHTML() : $this->tagHTML; + $pageletHTML .= !BigPipe::isEnabled() ? $this->getHTML() : $this->tagHTML; $pageletHTML .= "</{$this->tagName}>"; return $pageletHTML; |