From: Matthias Schmidt Date: Sun, 24 May 2015 09:43:06 +0000 (+0200) Subject: Load dashboard boxes in two steps internally X-Git-Tag: 3.0.0_Beta_1~2329 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d58d03331d9dea8d21e7b50290e0f5b5e5dd2660;p=GitHub%2FWoltLab%2FWCF.git Load dashboard boxes in two steps internally First, initialize all boxes and only after that, compile the templates. This change allows to cache object ids in init() in factories which fetch all required objects at once when getting the required objects in the render() method. --- diff --git a/wcfsetup/install/files/lib/system/dashboard/DashboardHandler.class.php b/wcfsetup/install/files/lib/system/dashboard/DashboardHandler.class.php index ecb8aead2c..b73c317699 100644 --- a/wcfsetup/install/files/lib/system/dashboard/DashboardHandler.class.php +++ b/wcfsetup/install/files/lib/system/dashboard/DashboardHandler.class.php @@ -60,7 +60,11 @@ class DashboardHandler extends SingletonFactory { } } - $contentTemplate = $sidebarTemplate = ''; + // 1. initialize all boxes first + $boxObjects = array( + 'content' => array(), + 'sidebar' => array() + ); foreach ($boxIDs as $boxID) { $className = $this->boxCache[$boxID]->className; if (!ClassUtil::isInstanceOf($className, 'wcf\system\dashboard\box\IDashboardBox')) { @@ -70,12 +74,16 @@ class DashboardHandler extends SingletonFactory { $boxObject = new $className(); $boxObject->init($this->boxCache[$boxID], $page); - if ($this->boxCache[$boxID]->boxType == 'content') { - $contentTemplate .= $boxObject->getTemplate(); - } - else { - $sidebarTemplate .= $boxObject->getTemplate(); - } + $boxObjects[$this->boxCache[$boxID]->boxType][] = $boxObject; + } + + // 2. fetch all templates + $contentTemplate = $sidebarTemplate = ''; + foreach ($boxObjects['content'] as $box) { + $contentTemplate .= $box->getTemplate(); + } + foreach ($boxObjects['sidebar'] as $box) { + $sidebarTemplate .= $box->getTemplate(); } WCF::getTPL()->assign(array(