Skip to content

Commit

Permalink
Add ViewHelper
Browse files Browse the repository at this point in the history
Closes #35
  • Loading branch information
Konafets committed Mar 20, 2018
1 parent d4c6f8f commit 018409b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
29 changes: 29 additions & 0 deletions Classes/ViewHelpers/DebugbarViewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php namespace Konafets\Typo3Debugbar\ViewHelpers;

use Konafets\Typo3Debugbar\Overrides\DebuggerUtility;
use Konafets\Typo3Debugbar\Typo3DebugBar;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;

class DebugbarViewHelper extends AbstractViewHelper
{
/**
* Displays the debug information in the PHP Debug Bar
*
* @param null|string $content
*/
public function render($content = null)

This comment has been minimized.

Copy link
@NamelessCoder

NamelessCoder May 22, 2018

Friendly reminder: render method arguments are long deprecated in Fluid.

{
if(is_null($content)) {
$content = $this->renderChildren();
}

/** @var Typo3DebugBar $debugBar */
$debugBar = GeneralUtility::makeInstance(Typo3DebugBar::class);
if ($debugBar->isEnabled()) {
DebuggerUtility::var_dump($content);
}

return;
}
}
17 changes: 15 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -155,14 +155,25 @@ 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:

.. 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}

<k:debugbar>{teaser}</k:debugbar>

*********
Lifecycle
*********
Expand All @@ -182,6 +193,8 @@ Debugbar <https://github.com/barryvdh/laravel-debugbar>`__. Thanks for
your good work `Barry vd. Heuvel <https://github.com/barryvdh>`__. 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
Expand Down

0 comments on commit 018409b

Please sign in to comment.