From 018409b6160bbaeb6ccf6709beac34c50612eecb Mon Sep 17 00:00:00 2001 From: Stefano Kowalke Date: Tue, 20 Mar 2018 14:38:59 +0100 Subject: [PATCH] Add ViewHelper Closes #35 --- Classes/ViewHelpers/DebugbarViewHelper.php | 29 ++++++++++++++++++++++ README.rst | 17 +++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 Classes/ViewHelpers/DebugbarViewHelper.php diff --git a/Classes/ViewHelpers/DebugbarViewHelper.php b/Classes/ViewHelpers/DebugbarViewHelper.php new file mode 100644 index 0000000..6efdbf5 --- /dev/null +++ b/Classes/ViewHelpers/DebugbarViewHelper.php @@ -0,0 +1,29 @@ +renderChildren(); + } + + /** @var Typo3DebugBar $debugBar */ + $debugBar = GeneralUtility::makeInstance(Typo3DebugBar::class); + if ($debugBar->isEnabled()) { + DebuggerUtility::var_dump($content); + } + + return; + } +} \ No newline at end of file diff --git a/README.rst b/README.rst index 909c57d..a217a64 100644 --- a/README.rst +++ b/README.rst @@ -75,7 +75,7 @@ can get the same instance via ``debugbar()``. This opens the possibility to interact with the DebugBar from within TYPO3. Log Exceptions --------------- +^^^^^^^^^^^^^ .. code:: php @@ -155,7 +155,7 @@ and its unclear if the DebugBar is enabled or not. Classical *Chicken-and-egg* problem. VarDump --------- +------- Everybody knows the output of DebugUtility::var_dump() ... and everybody knows that it breaks the layout. Lets move the output to the TYPO3 Debugbar. Use ``Konafets\Typo3Debugbar\Overrides\DebuggerUtility::var_dump($variable)`` and get an output like this: @@ -163,6 +163,17 @@ to the TYPO3 Debugbar. Use ``Konafets\Typo3Debugbar\Overrides\DebuggerUtility::v .. figure:: https://raw.githubusercontent.com/konafets/typo3_debugbar/develop/Documentation/Images/VarDumpPane.png :alt: VarDumpPane +ViewHelper +---------- + +The extension comes with a ViewHelper included to pipe the content of a variable to the DebugBar. + +.. code:: html + + {namespace k=Konafets\Typo3Debugbar\ViewHelpers} + + {teaser} + ********* Lifecycle ********* @@ -182,6 +193,8 @@ Debugbar `__. Thanks for your good work `Barry vd. Heuvel `__. I also copied the idea of a ServiceProvider from Laravel. +The idea and the initial version of the ViewHelper was provided by @KaffDaddy. + .. |Build Status| image:: https://travis-ci.org/Konafets/typo3_debugbar.svg?branch=master :target: https://travis-ci.org/Konafets/typo3_debugbar .. |Latest Stable Version| image:: https://poser.pugx.org/konafets/typo3_debugbar/v/stable