Using Box::render() instead of Box::__toString()
authorAlexander Ebert <ebert@woltlab.com>
Wed, 6 Jan 2016 15:46:16 +0000 (16:46 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 6 Jan 2016 15:46:16 +0000 (16:46 +0100)
`__toString()` is not allowed to throw any exception (for whatever
reason, this is php I guess), causing a real pain when trying to debug
errors. All though `__toString()` is the most elegant way, it turned out
to be less practical hence all occurences have been replaced with
`render()` instead.

com.woltlab.wcf/templates/footer.tpl
com.woltlab.wcf/templates/header.tpl
com.woltlab.wcf/templates/pageFooter.tpl
com.woltlab.wcf/templates/pageHeader.tpl
com.woltlab.wcf/templates/pageHeaderMenu.tpl
wcfsetup/install/files/lib/data/box/Box.class.php

index 2cc8504a717c9dc02373a9a79805b06076dcb2d0..a86014672d85bba4b4dcbda17aef3be07395cd91 100644 (file)
@@ -5,7 +5,7 @@
                                                <div class="boxContainer">
                                                        {content}
                                                                {foreach from=$__wcf->getBoxHandler()->getBoxes('contentBottom') item=box}
-                                                                       {@$box}
+                                                                       {@$box->render()}
                                                                {/foreach}
                                                        {/content}
                                                </div>  
@@ -35,7 +35,7 @@
                                                        {/if}
                                                        
                                                        {foreach from=$__wcf->getBoxHandler()->getBoxes('sidebarRight') item=box}
-                                                               {@$box}
+                                                               {@$box->render()}
                                                        {/foreach}
                                                
                                                        {event name='boxesSidebarRightBottom'}
@@ -52,7 +52,7 @@
                                <div class="boxContainer">
                                        {content}
                                                {foreach from=$__wcf->getBoxHandler()->getBoxes('bottom') item=box}
-                                                       {@$box}
+                                                       {@$box->render()}
                                                {/foreach}
                                        {/content}
                                </div>  
@@ -68,7 +68,7 @@
                                                {if !$footerBoxes|empty}{@$footerBoxes}{/if}
                                        
                                                {foreach from=$__wcf->getBoxHandler()->getBoxes('footerBoxes') item=box}
-                                                       {@$box}
+                                                       {@$box->render()}
                                                {/foreach}
                                        {/content}
                                </div>  
index 0d35123630d2964997e52701aa27a9f62e492ca0..c6e8bd4429fcda5a13806f306e313ea3b3a25e67 100644 (file)
@@ -13,7 +13,7 @@
                                <div class="boxContainer">
                                        {content}
                                                {foreach from=$__wcf->getBoxHandler()->getBoxes('headerBoxes') item=box}
-                                                       {@$box}
+                                                       {@$box->render()}
                                                {/foreach}
                                        {/content}
                                </div>  
@@ -29,7 +29,7 @@
                                <div class="boxContainer">
                                        {content}
                                                {foreach from=$__wcf->getBoxHandler()->getBoxes('top') item=box}
-                                                       {@$box}
+                                                       {@$box->render()}
                                                {/foreach}
                                        {/content}
                                </div>  
@@ -59,7 +59,7 @@
                                                        {/if}
                                                        
                                                        {foreach from=$__wcf->getBoxHandler()->getBoxes('sidebarLeft') item=box}
-                                                               {@$box}
+                                                               {@$box->render()}
                                                        {/foreach}
                                
                                                        {event name='boxesSidebarLeftBottom'}
@@ -78,7 +78,7 @@
                                                <div class="boxContainer">
                                                        {content}
                                                                {foreach from=$__wcf->getBoxHandler()->getBoxes('contentTop') item=box}
-                                                                       {@$box}
+                                                                       {@$box->render()}
                                                                {/foreach}
                                                        {/content}
                                                </div>  
index 2f6c23fcee731da8f148caab9e4430cd916d7e39..322c8f4ba2d32eed5b8e1b5eb36e5cdce52552f3 100644 (file)
@@ -5,7 +5,7 @@
                                <div class="boxContainer">
                                        {content}
                                                {foreach from=$__wcf->getBoxHandler()->getBoxes('footer') item=box}
-                                                       {@$box}
+                                                       {@$box->render()}
                                                {/foreach}
                                        {/content}
                                </div>  
index 200dce29a270d35e096a8a0b10164fe89c143770..345e9db9e511b3373ad25c17ab533bf59f467fa9 100644 (file)
@@ -33,7 +33,7 @@
                                <div class="boxContainer">
                                        {content}
                                                {foreach from=$__wcf->getBoxHandler()->getBoxes('hero') item=box}
-                                                       {@$box}
+                                                       {@$box->render()}
                                                {/foreach}
                                        {/content}
                                </div>  
index fab563ca1badf56d18006f5ebdd8ad8aaeb170fd..b31bbf463fa5aa1b3b093ede432b9d759658f596 100644 (file)
@@ -1,4 +1,4 @@
-{@$__wcf->getBoxHandler()->getBoxes('mainMenu')[0]}
+{@$__wcf->getBoxHandler()->getBoxes('mainMenu')[0]->render()}
 {*if $__wcf->getPageMenu()->getMenuItems('header')|count > 0}
        <nav id="mainMenu" class="mainMenu jsMobileNavigation" data-button-label="{lang}wcf.page.mainMenu{/lang}">
                <ul>
index 6c591bc5a479d7d5275aab1c49ae74f9215678a2..b9e19c9f6304e66335bbd38b01b17c59310dcaf1 100644 (file)
@@ -164,7 +164,7 @@ class Box extends DatabaseObject {
         * 
         * @return      string
         */
-       public function __toString() {
+       public function render() {
                if (!$this->hasContent()) return ''; 
                
                WCF::getTPL()->assign([