9use Symfony\Component\VarDumper\Caster\Caster;
10use Symfony\Component\VarDumper\Cloner\AbstractCloner;
11use Symfony\Component\VarDumper\Cloner\VarCloner;
12use Symfony\Component\VarDumper\Dumper\HtmlDumper;
49 $this->applicationRootPath = dirname(dirname(dirname(dirname(dirname(dirname(__DIR__))))));
64 if (defined(
"ENT_SUBSTITUTE") && !defined(
"HHVM_VERSION")) {
65 $flags |= ENT_SUBSTITUTE;
74 $raw = str_replace(chr(9),
' ', $raw);
76 return htmlspecialchars($raw, $flags,
"UTF-8");
88 $escaped = $this->
escape($raw);
90 "@([A-z]+?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@",
91 "<a href=\"$1\" target=\"_blank\" rel=\"noreferrer noopener\">$1</a>",
106 foreach ($parts as &$part) {
107 $part =
'<div class="delimiter">' . $part .
'</div>';
121 if ($this->applicationRootPath !=
"/") {
122 $path = str_replace($this->applicationRootPath,
'…',
$path);
130 if (!$this->htmlDumper && class_exists(
'Symfony\Component\VarDumper\Cloner\VarCloner')) {
133 $this->htmlDumper =
new HtmlDumper($this->htmlDumperOutput);
136 'default' =>
'color:#FFFFFF; line-height:normal; font:12px "Inconsolata", "Fira Mono", "Source Code Pro", Monaco, Consolas, "Lucida Console", monospace !important; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: normal',
137 'num' =>
'color:#BCD42A',
138 'const' =>
'color: #4bb1b1;',
139 'str' =>
'color:#BCD42A',
140 'note' =>
'color:#ef7c61',
141 'ref' =>
'color:#A0A0A0',
142 'public' =>
'color:#FFFFFF',
143 'protected' =>
'color:#FFFFFF',
144 'private' =>
'color:#FFFFFF',
145 'meta' =>
'color:#FFFFFF',
146 'key' =>
'color:#BCD42A',
147 'index' =>
'color:#ef7c61',
149 $this->htmlDumper->setStyles($styles);
168 if (class_exists(
'Symfony\Component\VarDumper\Caster\Caster')) {
169 $cloneVar = $this->
getCloner()->cloneVar($value, Caster::EXCLUDE_VERBOSE);
172 $cloneVar = $this->
getCloner()->cloneVar($value);
177 $this->htmlDumperOutput
180 $output = $this->htmlDumperOutput->getOutput();
181 $this->htmlDumperOutput->clear();
186 return htmlspecialchars(print_r($value,
true));
203 $numFrames = count($frame->
getArgs());
205 if ($numFrames > 0) {
206 $html =
'<ol class="linenums">';
207 foreach ($frame->
getArgs() as $j => $frameArg) {
208 $html .=
'<li>'. $this->
dump($frameArg) .
'</li>';
222 public function slug($original)
224 $slug = str_replace(
" ",
"-", $original);
225 $slug = preg_replace(
'/[^\w\d\-\_]/i',
'', $slug);
226 return strtolower($slug);
244 if ($additionalVariables !==
null) {
248 call_user_func(
function () {
249 extract(func_get_arg(1));
250 require func_get_arg(0);
273 $this->variables[$variableName] = $variableValue;
286 return isset($this->variables[$variableName]) ?
287 $this->variables[$variableName] : $defaultValue;
297 unset($this->variables[$variableName]);
327 if (!$this->cloner) {
328 $this->cloner =
new VarCloner();
An exception for terminatinating execution or to throw for unit testing.
Used as output callable for Symfony\Component\VarDumper\Dumper\HtmlDumper::dump()
Exposes useful tools for working with/in templates.
getVariable($variableName, $defaultValue=null)
Gets a single template variable, by its name, or $defaultValue if the variable does not exist.
setVariables(array $variables)
Sets the variables to be passed to all templates rendered by this template helper.
slug($original)
Convert a string to a slug version of itself.
getApplicationRootPath()
Return the application root path.
breakOnDelimiter($delimiter, $s)
Makes sure that the given string breaks on the delimiter.
shorten($path)
Replace the part of the path that all files have in common.
delVariable($variableName)
Unsets a single template variable, by its name.
setApplicationRootPath($applicationRootPath)
Set the application root path.
dumpArgs(Frame $frame)
Format the args of the given Frame as a human readable html string.
escapeButPreserveUris($raw)
Escapes a string for output in an HTML document, but preserves URIs within it, and converts them to c...
getCloner()
Get the cloner used for dumping variables.
render($template, array $additionalVariables=null)
Given a template path, render it within its own scope.
dump($value)
Format the given value into a human readable string.
escape($raw)
Escapes a string for output in an HTML document.
setCloner($cloner)
Set the cloner used for dumping variables.
setVariable($variableName, $variableValue)
Sets a single template variable, by its name:
getVariables()
Returns all variables for this helper.
Whoops - php errors for cool kids.