Skip to content

Commit

Permalink
Backward compatibility with Magento without VarDumper, thanks to @dud…
Browse files Browse the repository at this point in the history
  • Loading branch information
vpietri committed Jun 22, 2024
1 parent 077b6fe commit b137dfb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
5 changes: 5 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ public function getCacheFrontendPool()

public function getQdbConfig($key, $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null)
{
// Backward compatibility
if($key=='handle_vardumper' && !class_exists(\Symfony\Component\VarDumper\VarDumper::class)) {
return false;
}

return $this->getConfig('dev/quickdevbar/'.$key, $scopeType, $scopeCode);
}

Expand Down
10 changes: 3 additions & 7 deletions Plugin/Framework/App/FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
use ADM\QuickDevBar\Helper\Register;
use ADM\QuickDevBar\Service\Dumper;
use Magento\Framework\App\RequestInterface;
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
use Symfony\Component\VarDumper\VarDumper;
use Symfony\Component\VarDumper\Cloner\VarCloner;


class FrontController
{
Expand Down Expand Up @@ -63,7 +59,7 @@ public function beforeDispatch(\Magento\Framework\App\FrontControllerInterface $
if($this->request->isAjax() && $enabledHandler<2) {
return;
}
//$prevHandler = VarDumper::setHandler($this->dumperHandler(...));
$prevHandler = \Symfony\Component\VarDumper\VarDumper::setHandler($this->dumperHandler(...));
}
}

Expand All @@ -73,8 +69,8 @@ public function beforeDispatch(\Magento\Framework\App\FrontControllerInterface $
*/
protected function dumperHandler($var)
{
$cloner = new VarCloner();
$dumper = new HtmlDumper();
$cloner = new \Symfony\Component\VarDumper\Cloner\VarCloner();
$dumper = new \Symfony\Component\VarDumper\Dumper\HtmlDumper();

$dumper->setTheme('dark');
$dumpBt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)[2];
Expand Down
5 changes: 5 additions & 0 deletions view/base/templates/tab/dumper.phtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php
/** @var $block \ADM\QuickDevBar\Block\Tab\Panel */
?>
<?php if(!$block->getQdbConfig('handle_vardumper')):?>
<p>You need to activate admin configuration and having VarDumper Component installed, see <a href="https://github.com/symfony/var-dumper">github.com/symfony/var-dumper</a></p>
<?php endif; ?>



<?php if(!$block->getDumps()): ?>
<div class="qdb-dump"></div>
Expand Down

0 comments on commit b137dfb

Please sign in to comment.