From dc0b1a382b5f980cffe87e9965e659d07107026e Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Sun, 10 Jul 2016 11:24:33 +0200 Subject: Each resource has now an ID; Code improvements and comment blocks added. --- include/classes/BigPipe/BigPipe.php | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'include/classes/BigPipe/BigPipe.php') 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 @@ ] # +#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%# +# # +# 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"; } -- cgit v1.2.3