Skip to content

[DataCollector] Improves the readability of the collected arrays in the profiler. #10150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@
margin-left: 250px;
padding: 30px 40px 40px;
}
.tree .errors {
color: #aa3333;
}
.tree .active.errors {
color: #aa3333;
}
.form-type {
color: #999999;
}
Expand Down Expand Up @@ -173,7 +179,7 @@

{% macro form_tree_entry(name, data) %}
<li>
<a href="#details_{{ data.id }}">{{ name }}</a>
<a{% if data.errors is defined and data.errors|length > 0 %} class="errors"{% endif %} href="#details_{{ data.id }}">{{ name }}</a>

{% if data.children is not empty %}
<ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FormDataExtractorTest_SimpleValueExporter extends ValueExporter
/**
* {@inheritdoc}
*/
public function exportValue($value)
public function exportValue($value, $depth = 0)
{
return var_export($value, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,29 @@ class ValueExporter
* Converts a PHP value to a string.
*
* @param mixed $value The PHP value
* @param integer $depth The depth of the value to export
*
* @return string The string representation of the given value
*/
public function exportValue($value)
public function exportValue($value, $depth = 0)
{
if (is_object($value)) {
return sprintf('Object(%s)', get_class($value));
}

if (is_array($value) && empty($value)) {
return '[]';
}

if (is_array($value)) {
$indent = str_repeat(' ', $depth);

$a = array();
foreach ($value as $k => $v) {
$a[] = sprintf('%s => %s', $k, $this->exportValue($v));
$a[] = sprintf('%s %s => %s', $indent, $k, $this->exportValue($v, $depth + 1));
}

return sprintf("Array(%s)", implode(', ', $a));
return sprintf("[\n%s%s\n%s]", $indent, implode(sprintf(", \n%s", $indent), $a), $indent);
}

if (is_resource($value)) {
Expand Down