diff options
author | Thomas Lange <code@nerdmind.de> | 2017-10-21 23:54:41 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2017-10-21 23:54:41 +0200 |
commit | bcf23c3ab443567991d602f6d06d87051aa3468b (patch) | |
tree | 4d566c8b8b2c7c7180900b4a60929eed27780cdb /include/classes/BigPipe/Pagelet.php | |
parent | 80420baa5b6c42f016c041bc13264382cc50d698 (diff) | |
download | bigpipe-bcf23c3ab443567991d602f6d06d87051aa3468b.tar.gz bigpipe-bcf23c3ab443567991d602f6d06d87051aa3468b.tar.xz bigpipe-bcf23c3ab443567991d602f6d06d87051aa3468b.zip |
Code optimization: The method "getStructure" has been added to the abstract Item class.
Diffstat (limited to 'include/classes/BigPipe/Pagelet.php')
-rwxr-xr-x | include/classes/BigPipe/Pagelet.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/classes/BigPipe/Pagelet.php b/include/classes/BigPipe/Pagelet.php index 664883a..ae465ab 100755 --- a/include/classes/BigPipe/Pagelet.php +++ b/include/classes/BigPipe/Pagelet.php @@ -124,6 +124,30 @@ class Pagelet extends Item { } #=============================================================================== + # Return the pagelet structure + #=============================================================================== + public function getStructure(): array { + foreach($this->getResources()[Resource::TYPE_STYLESHEET] as $Resource) { + $stylesheets[] = $Resource->getStructure(); + } + + foreach($this->getResources()[Resource::TYPE_JAVASCRIPT] as $Resource) { + $javascripts[] = $Resource->getStructure(); + } + + return [ + 'ID' => $this->getID(), + 'NEED' => $this->getDependencies(), + 'RSRC' => [ + Resource::TYPE_STYLESHEET => $stylesheets ?? [], + Resource::TYPE_JAVASCRIPT => $javascripts ?? [] + ], + 'CODE' => removeLineBreaksAndTabs($this->getJSCode()), + 'PHASE' => $this->getPhaseDoneJS() + ]; + } + + #=============================================================================== # Magic method: __toString() #=============================================================================== public function __toString() { |