aboutsummaryrefslogtreecommitdiffstats
path: root/include/classes/BigPipe/Pagelet.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2016-10-22 01:08:22 +0200
committerThomas Lange <code@nerdmind.de>2016-10-22 01:08:22 +0200
commit19c0af6809b8db0b763565fa9b273c90da3d1894 (patch)
tree9abe45611cb8bc90ab9f91f84309e65e8b9e08ce /include/classes/BigPipe/Pagelet.php
parent842379e0ca399bdb5f8b85c455d1136b519d1816 (diff)
downloadbigpipe-19c0af6809b8db0b763565fa9b273c90da3d1894.tar.gz
bigpipe-19c0af6809b8db0b763565fa9b273c90da3d1894.tar.xz
bigpipe-19c0af6809b8db0b763565fa9b273c90da3d1894.zip
The Pagelet representation class in PHP now has a separate method to add dependencies (either with the instance of the dependency Pagelet or the unique ID as string as argument).
Diffstat (limited to 'include/classes/BigPipe/Pagelet.php')
-rwxr-xr-xinclude/classes/BigPipe/Pagelet.php16
1 files changed, 13 insertions, 3 deletions
diff --git a/include/classes/BigPipe/Pagelet.php b/include/classes/BigPipe/Pagelet.php
index 0df117c..df74876 100755
--- a/include/classes/BigPipe/Pagelet.php
+++ b/include/classes/BigPipe/Pagelet.php
@@ -34,9 +34,8 @@ class Pagelet extends Item {
const PHASE_LOADJS = 3; # After all the JS resources have been loaded
const PHASE_DONE = 4; # After the static JS code has been executed
- public function __construct($customID = NULL, $priority = self::PRIORITY_NORMAL, array $dependencies = []) {
+ public function __construct($customID = NULL, $priority = self::PRIORITY_NORMAL) {
$this->ID = $customID ?? 'P'.++self::$count;
- $this->dependencies = $dependencies;
$this->resources = array_pad($this->resources, 2, []);
$this->phaseDoneJS = array_pad($this->phaseDoneJS, 5, []);
@@ -69,7 +68,7 @@ class Pagelet extends Item {
# Return all display dependencies
#===============================================================================
public function getDependencies(): array {
- return $this->dependencies;
+ return array_unique($this->dependencies);
}
#===============================================================================
@@ -108,6 +107,17 @@ class Pagelet extends Item {
}
#===============================================================================
+ # Attach a display dependency
+ #===============================================================================
+ public function addDependency($Pagelet) {
+ if($Pagelet instanceof Pagelet) {
+ return $this->dependencies[] = $Pagelet->getID();
+ }
+
+ return $this->dependencies[] = $Pagelet;
+ }
+
+ #===============================================================================
# Set custom placeholder tagname
#===============================================================================
public function setTagname($tagname) {