aboutsummaryrefslogtreecommitdiffstats
path: root/include/classes/BigPipe/BigPipe.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2016-07-10 11:24:33 +0200
committerThomas Lange <code@nerdmind.de>2016-07-10 11:24:33 +0200
commitdc0b1a382b5f980cffe87e9965e659d07107026e (patch)
treed05bd1dc5a7140caf40bb19483c93e0fe0a757f4 /include/classes/BigPipe/BigPipe.php
parent28f2ba2a44ca932e16ba6791a07ed42b62fe6803 (diff)
downloadbigpipe-dc0b1a382b5f980cffe87e9965e659d07107026e.tar.gz
bigpipe-dc0b1a382b5f980cffe87e9965e659d07107026e.tar.xz
bigpipe-dc0b1a382b5f980cffe87e9965e659d07107026e.zip
Each resource has now an ID; Code improvements and comment blocks added.
Diffstat (limited to 'include/classes/BigPipe/BigPipe.php')
-rwxr-xr-xinclude/classes/BigPipe/BigPipe.php33
1 files changed, 21 insertions, 12 deletions
diff --git a/include/classes/BigPipe/BigPipe.php b/include/classes/BigPipe/BigPipe.php
index 082ca14..8d95779 100755
--- a/include/classes/BigPipe/BigPipe.php
+++ b/include/classes/BigPipe/BigPipe.php
@@ -1,4 +1,13 @@
<?php
+#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
+# BigPipe main class [Thomas Lange <tl@nerdmind.de>] #
+#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
+# #
+# The BigPipe main class is responsible for sorting and rendering the pagelets #
+# and their associated resources. This class also provides methods to turn off #
+# the pipelining mode or turn on the debugging mode. #
+# #
+#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
namespace BigPipe;
class BigPipe {
@@ -44,8 +53,8 @@ class BigPipe {
if(self::debugging()) {
self::addDebugPhaseDoneJS($Pagelet);
- array_map('self::addDebugPhaseDoneJS', $Pagelet->getCSSResources());
- array_map('self::addDebugPhaseDoneJS', $Pagelet->getJSResources());
+ array_map('self::addDebugPhaseDoneJS', $Pagelet->getResources()[Resource::TYPE_STYLESHEET]);
+ array_map('self::addDebugPhaseDoneJS', $Pagelet->getResources()[Resource::TYPE_JAVASCRIPT]);
usleep(rand(125, 175) * 2000);
}
@@ -53,20 +62,20 @@ class BigPipe {
$stylesheets = [];
$javascripts = [];
- foreach($Pagelet->getCSSResources() as $Resource) {
- $stylesheets[$Resource->getURL()] = $Resource->getPhaseDoneJS();
+ foreach($Pagelet->getResources()[Resource::TYPE_STYLESHEET] as $Resource) {
+ $stylesheets[] = ['ID' => $Resource->getID(), 'HREF' => $Resource->getURL(), 'PHASE' => $Resource->getPhaseDoneJS()];
}
- foreach($Pagelet->getJSResources() as $Resource) {
- $javascripts[$Resource->getURL()] = $Resource->getPhaseDoneJS();
+ foreach($Pagelet->getResources()[Resource::TYPE_JAVASCRIPT] as $Resource) {
+ $javascripts[] = ['ID' => $Resource->getID(), 'HREF' => $Resource->getURL(), 'PHASE' => $Resource->getPhaseDoneJS()];
}
$pageletJSON = [
- 'ID' => $Pagelet->getID(),
+ 'ID' => $Pagelet->getID(),
'NEED' => $Pagelet->getDependencies(),
- 'RSRC' => (object) [
- Resource::TYPE_STYLESHEET => (object) $stylesheets,
- Resource::TYPE_JAVASCRIPT => (object) $javascripts,
+ 'RSRC' => [
+ Resource::TYPE_STYLESHEET => $stylesheets,
+ Resource::TYPE_JAVASCRIPT => $javascripts,
],
'CODE' => removeLineBreaksAndTabs($Pagelet->getJSCode()),
'PHASE' => $Pagelet->getPhaseDoneJS()
@@ -105,11 +114,11 @@ class BigPipe {
foreach(array_reverse(self::$pagelets) as $priority => $pagelets) {
foreach($pagelets as $Pagelet) {
if(!self::enabled()) {
- foreach($Pagelet->getCSSResources() as $Resource) {
+ foreach($Pagelet->getResources()[Resource::TYPE_STYLESHEET] as $Resource) {
echo $Resource->renderHTML()."\n";
}
- foreach($Pagelet->getJSResources() as $Resource) {
+ foreach($Pagelet->getResources()[Resource::TYPE_JAVASCRIPT] as $Resource) {
echo $Resource->renderHTML()."\n";
}