[TASK] Optimize invocation of cObj::checkIf
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / ContentObject / HierarchicalMenuContentObject.php
index b4034e9..235c327 100644 (file)
@@ -28,30 +28,33 @@ class HierarchicalMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Ab
         * @return string Output
         */
        public function render($conf = array()) {
+               if (!empty($conf['if.']) && !$this->cObj->checkIf($conf['if.'])) {
+                       return '';
+               }
+
                $theValue = '';
-               if ($this->cObj->checkIf($conf['if.'])) {
-                       $menuType = $conf[1];
-                       try {
-                               $menuObjectFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\Menu\\MenuContentObjectFactory');
-                               $menu = $menuObjectFactory->getMenuObjectByType($menuType);
-                               $GLOBALS['TSFE']->register['count_HMENU']++;
-                               $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = 0;
-                               $GLOBALS['TSFE']->register['count_MENUOBJ'] = 0;
-                               $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] = array();
-                               $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId'] = array();
-                               $menu->parent_cObj = $this->cObj;
-                               $menu->start($GLOBALS['TSFE']->tmpl, $GLOBALS['TSFE']->sys_page, '', $conf, 1);
-                               $menu->makeMenu();
-                               $theValue .= $menu->writeMenu();
-                       } catch (\TYPO3\CMS\Frontend\ContentObject\Menu\Exception\NoSuchMenuTypeException $e) {
-                       }
-                       $wrap = isset($conf['wrap.']) ? $this->cObj->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];
-                       if ($wrap) {
-                               $theValue = $this->cObj->wrap($theValue, $wrap);
-                       }
-                       if (isset($conf['stdWrap.'])) {
-                               $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
-                       }
+               $menuType = $conf[1];
+               try {
+                       /** @var $menuObjectFactory \TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory */
+                       $menuObjectFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\Menu\\MenuContentObjectFactory');
+                       $menu = $menuObjectFactory->getMenuObjectByType($menuType);
+                       $GLOBALS['TSFE']->register['count_HMENU']++;
+                       $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = 0;
+                       $GLOBALS['TSFE']->register['count_MENUOBJ'] = 0;
+                       $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] = array();
+                       $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId'] = array();
+                       $menu->parent_cObj = $this->cObj;
+                       $menu->start($GLOBALS['TSFE']->tmpl, $GLOBALS['TSFE']->sys_page, '', $conf, 1);
+                       $menu->makeMenu();
+                       $theValue .= $menu->writeMenu();
+               } catch (\TYPO3\CMS\Frontend\ContentObject\Menu\Exception\NoSuchMenuTypeException $e) {
+               }
+               $wrap = isset($conf['wrap.']) ? $this->cObj->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];
+               if ($wrap) {
+                       $theValue = $this->cObj->wrap($theValue, $wrap);
+               }
+               if (isset($conf['stdWrap.'])) {
+                       $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
                }
                return $theValue;
        }