diff options
Diffstat (limited to 'include/classes/BigPipe')
-rwxr-xr-x | include/classes/BigPipe/BigPipe.php | 2 | ||||
-rwxr-xr-x | include/classes/BigPipe/DemoPagelet.php | 4 | ||||
-rwxr-xr-x | include/classes/BigPipe/Pagelet.php | 11 |
3 files changed, 13 insertions, 4 deletions
diff --git a/include/classes/BigPipe/BigPipe.php b/include/classes/BigPipe/BigPipe.php index 8cdda0b..1af4d8a 100755 --- a/include/classes/BigPipe/BigPipe.php +++ b/include/classes/BigPipe/BigPipe.php @@ -34,7 +34,7 @@ class BigPipe { #=============================================================================== private static function singleResponse(Pagelet $Pagelet, $last = FALSE) { $pageletJSON = [ - 'ID' => $Pagelet->getID(), + 'ID' => $Pagelet->getID(), 'NEED' => $Pagelet->getDependencies(), 'RESOURCES' => ['CSS' => $Pagelet->getCSSFiles(), 'JS' => $Pagelet->getJSFiles(), 'JS_CODE' => removeLineBreaksAndTabs($Pagelet->getJSCode())], 'PHASES' => (object) $Pagelet->getPhaseDoneJS() ]; diff --git a/include/classes/BigPipe/DemoPagelet.php b/include/classes/BigPipe/DemoPagelet.php index 83689ba..adb9f89 100755 --- a/include/classes/BigPipe/DemoPagelet.php +++ b/include/classes/BigPipe/DemoPagelet.php @@ -3,8 +3,8 @@ namespace BigPipe; class DemoPagelet extends Pagelet { - public function __construct($customID = NULL, $priority = Pagelet::PRIORITY_NORMAL) { - parent::__construct($customID, $priority); + public function __construct($customID = NULL, $priority = Pagelet::PRIORITY_NORMAL, array $dependencies = []) { + parent::__construct($customID, $priority, $dependencies); $message = '%s: PhaseDoneJS for phase %s'; diff --git a/include/classes/BigPipe/Pagelet.php b/include/classes/BigPipe/Pagelet.php index 22aadce..436e12a 100755 --- a/include/classes/BigPipe/Pagelet.php +++ b/include/classes/BigPipe/Pagelet.php @@ -8,6 +8,7 @@ class Pagelet { private $JSFiles = []; private $CSSFiles = []; private $phaseDoneJS = []; + private $dependencies = []; private $tagname = 'div'; private static $count = 0; @@ -29,8 +30,9 @@ class Pagelet { const PHASE_LOADJS = 3; # After all the JS resources have been loaded const PHASE_EXECJS = 4; # After the static JS code has been executed - public function __construct($customID = NULL, $priority = self::PRIORITY_NORMAL) { + public function __construct($customID = NULL, $priority = self::PRIORITY_NORMAL, array $dependencies = []) { $this->phaseDoneJS = array_pad($this->phaseDoneJS, 5, []); + $this->dependencies = $dependencies; $this->ID = is_string($customID) ? $customID : 'P'.++self::$count; BigPipe::addPagelet($this, $priority); @@ -114,6 +116,13 @@ class Pagelet { } #=============================================================================== + # Return all display dependencies + #=============================================================================== + public function getDependencies(): array { + return $this->dependencies; + } + + #=============================================================================== # Set custom placeholder tagname #=============================================================================== public function setTagname($tagname) { |