[FEATURE] Add fluid debug information to admin panel
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / Core / ViewHelper / ViewHelperResolver.php
index b2b854e..32e69d5 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Fluid\Core\ViewHelper;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
@@ -52,6 +53,20 @@ class ViewHelperResolver extends \TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperRes
         ]
     ];
 
+    /**
+     * ViewHelperResolver constructor
+     *
+     * Responsible for adding a third namespace in case this is requested from
+     * the admin panel - causes overlaying of `f:` with `f:debug`.
+     */
+    public function __construct()
+    {
+        $configuration = $this->getBackendUser()->uc['TSFE_adminConfig'];
+        if (isset($configuration['preview_showFluidDebug']) && $configuration['preview_showFluidDebug']) {
+            $this->namespaces['f'][] = 'TYPO3\\CMS\\Fluid\\ViewHelpers\\Debug';
+        }
+    }
+
     /**
      * @param string $viewHelperClassName
      * @return \TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInterface
@@ -68,4 +83,12 @@ class ViewHelperResolver extends \TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperRes
     {
         return GeneralUtility::makeInstance(ObjectManager::class);
     }
+
+    /**
+     * @return BackendUserAuthentication
+     */
+    protected function getBackendUser()
+    {
+        return $GLOBALS['BE_USER'];
+    }
 }