mirror of
https://github.com/filp/whoops.git
synced 2026-09-11 10:16:25 +00:00
Allow to set the cloner
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
namespace Whoops\Util;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\AbstractCloner;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
|
||||
use Whoops\Exception\Frame;
|
||||
@@ -31,6 +32,11 @@ class TemplateHelper
|
||||
*/
|
||||
private $htmlDumperOutput;
|
||||
|
||||
/**
|
||||
* @var AbstractCloner
|
||||
*/
|
||||
private $cloner;
|
||||
|
||||
/**
|
||||
* Escapes a string for output in an HTML document
|
||||
*
|
||||
@@ -110,10 +116,11 @@ class TemplateHelper
|
||||
$dumper = $this->getDumper();
|
||||
|
||||
if ($dumper) {
|
||||
$cloner = new VarCloner();
|
||||
|
||||
// re-use the same DumpOutput instance, so it won't re-render the global styles/scripts on each dump.
|
||||
$dumper->dump($cloner->cloneVar($value), $this->htmlDumperOutput);
|
||||
$dumper->dump(
|
||||
$this->getCloner()->cloneVar($value),
|
||||
$this->htmlDumperOutput
|
||||
);
|
||||
|
||||
$output = $this->htmlDumperOutput->getOutput();
|
||||
$this->htmlDumperOutput->clear();
|
||||
@@ -244,4 +251,27 @@ class TemplateHelper
|
||||
{
|
||||
return $this->variables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cloner used for dumping variables.
|
||||
*
|
||||
* @param AbstractCloner $cloner
|
||||
*/
|
||||
public function setCloner($cloner)
|
||||
{
|
||||
$this->cloner = $cloner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cloner used for dumping variables.
|
||||
*
|
||||
* @return AbstractCloner
|
||||
*/
|
||||
public function getCloner()
|
||||
{
|
||||
if (!$this->cloner) {
|
||||
$this->cloner = new VarCloner();
|
||||
}
|
||||
return $this->cloner;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user