aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2016-03-26 14:01:09 +0100
committerThomas Lange <code@nerdmind.de>2016-03-26 14:01:09 +0100
commit74d01962a6f77eb2b8138864f18ed53eb136c432 (patch)
tree1d6de62cdea46b167fc08231e1805988c94477ad
parent1b951d0a00ec8b8255f56287fe36a51a5ed7ab75 (diff)
downloadbigpipe-74d01962a6f77eb2b8138864f18ed53eb136c432.tar.gz
bigpipe-74d01962a6f77eb2b8138864f18ed53eb136c432.tar.xz
bigpipe-74d01962a6f77eb2b8138864f18ed53eb136c432.zip
Custom pagelet ID's
-rwxr-xr-xinclude/classes/BigPipe/DemoPagelet.php4
-rwxr-xr-xinclude/classes/BigPipe/Pagelet.php4
-rwxr-xr-xindex.php2
3 files changed, 5 insertions, 5 deletions
diff --git a/include/classes/BigPipe/DemoPagelet.php b/include/classes/BigPipe/DemoPagelet.php
index a6c61e1..83689ba 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($priority = Pagelet::PRIORITY_NORMAL) {
- parent::__construct($priority);
+ public function __construct($customID = NULL, $priority = Pagelet::PRIORITY_NORMAL) {
+ parent::__construct($customID, $priority);
$message = '%s: PhaseDoneJS for phase %s';
diff --git a/include/classes/BigPipe/Pagelet.php b/include/classes/BigPipe/Pagelet.php
index d1c335f..3b5530c 100755
--- a/include/classes/BigPipe/Pagelet.php
+++ b/include/classes/BigPipe/Pagelet.php
@@ -28,9 +28,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($priority = self::PRIORITY_NORMAL) {
+ public function __construct($customID = NULL, $priority = self::PRIORITY_NORMAL) {
$this->phaseDoneJS = array_pad([], 5, []);
- $this->ID = 'P'.++self::$count;
+ $this->ID = is_string($customID) ? $customID : 'P'.++self::$count;
BigPipe::addPagelet($this, $priority);
}
diff --git a/index.php b/index.php
index a713b07..3386d5e 100755
--- a/index.php
+++ b/index.php
@@ -32,7 +32,7 @@ $PageletRed->addJSCode("document.getElementById('red').innerHTML += ' [JS execut
#====================================================================================================
# Pagelet with blue background color
#====================================================================================================
-$PageletBlue = new BigPipe\DemoPagelet(BigPipe\Pagelet::PRIORITY_HIGH);
+$PageletBlue = new BigPipe\DemoPagelet('customPageletID', BigPipe\Pagelet::PRIORITY_HIGH);
$PageletBlue->addHTML('<section id="blue" class="text">I AM A PAGELET WITH BLUE BACKGROUND</section>');
$PageletBlue->addCSS('static/blue.php');
$PageletBlue->addJS('static/delayJS.php');