diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml
index 874ba8b21624..ed7e923f0d05 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml
+++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml
@@ -8,6 +8,7 @@
Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController
Symfony\Bundle\WebProfilerBundle\Controller\RouterController
Symfony\Bundle\WebProfilerBundle\Controller\ExceptionController
+ Symfony\Bundle\WebProfilerBundle\Twig\WebProfilerExtension
@@ -30,5 +31,9 @@
%kernel.debug%
+
+
+
+
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/bag.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/bag.html.twig
index 8947c9a6cb17..b7a774db532d 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/bag.html.twig
+++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/bag.html.twig
@@ -1,16 +1,15 @@
- Key |
- Value |
+ Key |
+ Value |
{% for key in bag.keys|sort %}
{{ key }} |
- {# JSON_UNESCAPED_SLASHES = 64, JSON_UNESCAPED_UNICODE = 256 #}
- {{ bag.get(key)|json_encode(64 b-or 256) }} |
+ {{ profiler_dump(bag.get(key)) }} |
{% endfor %}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig
index 3b45ca11163e..5cc3ae149fa9 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig
+++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig
@@ -170,6 +170,10 @@ pre, code {
margin-left: 250px;
padding: 30px 40px 40px;
}
+#collector-content pre {
+ white-space: pre-wrap;
+ word-break: break-all;
+}
#navigation {
float: left;
width: 250px;
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/table.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/table.html.twig
index 1c5130dfba76..a5b6078eb6ad 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/table.html.twig
+++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/table.html.twig
@@ -1,16 +1,15 @@
- Key |
- Value |
+ Key |
+ Value |
{% for key in data|keys|sort %}
{{ key }} |
- {# JSON_UNESCAPED_SLASHES = 64, JSON_UNESCAPED_UNICODE = 256 #}
- {{ data[key]|json_encode(64 b-or 256) }} |
+ {{ profiler_dump(data[key]) }} |
{% endfor %}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php b/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php
new file mode 100644
index 000000000000..a6cb0bb6a327
--- /dev/null
+++ b/src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php
@@ -0,0 +1,54 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Bundle\WebProfilerBundle\Twig;
+
+use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
+
+/**
+ * Twig extension for the profiler
+ *
+ * @author Fabien Potencier
+ */
+class WebProfilerExtension extends \Twig_Extension
+{
+ /**
+ * @var ValueExporter
+ */
+ private $valueExporter;
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFunctions()
+ {
+ return array(
+ new \Twig_SimpleFunction('profiler_dump', array($this, 'dumpValue')),
+ );
+ }
+
+ public function dumpValue($value)
+ {
+ if (null === $this->valueExporter) {
+ $this->valueExporter = new ValueExporter();
+ }
+
+ return $this->valueExporter->exportValue($value);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getName()
+ {
+ return 'profiler';
+ }
+}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json
index 2911bd7f7fb0..c6e5ee51248a 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/composer.json
+++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json
@@ -17,7 +17,7 @@
],
"require": {
"php": ">=5.3.3",
- "symfony/http-kernel": "~2.2",
+ "symfony/http-kernel": "~2.3",
"symfony/routing": "~2.2",
"symfony/twig-bridge": "~2.2"
},
diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php
index 37b5b7d86cfb..06f7f8866d80 100644
--- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php
@@ -25,7 +25,7 @@ class FormDataExtractorTest_SimpleValueExporter extends ValueExporter
/**
* {@inheritdoc}
*/
- public function exportValue($value)
+ public function exportValue($value, $depth = 1, $deep = false)
{
return is_object($value) ? sprintf('object(%s)', get_class($value)) : var_export($value, true);
}
diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
index 4473605e843f..cc366186fc0f 100644
--- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
+++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
@@ -51,14 +51,10 @@ public function collect(Request $request, Response $response, \Exception $except
$attributes = array();
foreach ($request->attributes->all() as $key => $value) {
if ('_route' === $key && is_object($value)) {
- $attributes['_route'] = $this->varToString($value->getPath());
- } elseif ('_route_params' === $key) {
- foreach ($value as $key => $v) {
- $attributes['_route_params'][$key] = $this->varToString($v);
- }
- } else {
- $attributes[$key] = $this->varToString($value);
+ $value = $value->getPath();
}
+
+ $attributes[$key] = $value;
}
$content = null;
diff --git a/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php b/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php
index f3aeb80cb227..b378d093cd1e 100644
--- a/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php
+++ b/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php
@@ -19,23 +19,38 @@ class ValueExporter
/**
* Converts a PHP value to a string.
*
- * @param mixed $value The PHP value
+ * @param mixed $value The PHP value
+ * @param integer $depth only for internal usage
+ * @param Boolean $deep only for internal usage
*
* @return string The string representation of the given value
*/
- public function exportValue($value)
+ public function exportValue($value, $depth = 1, $deep = false)
{
if (is_object($value)) {
return sprintf('Object(%s)', get_class($value));
}
if (is_array($value)) {
+ if (empty($value)) {
+ return '[]';
+ }
+
+ $indent = str_repeat(' ', $depth);
+
$a = array();
foreach ($value as $k => $v) {
- $a[] = sprintf('%s => %s', $k, $this->exportValue($v));
+ if (is_array($v)) {
+ $deep = true;
+ }
+ $a[] = sprintf('%s => %s', $k, $this->exportValue($v, $depth + 1, $deep));
+ }
+
+ if ($deep) {
+ return sprintf("[\n%s%s\n%s]", $indent, implode(sprintf(", \n%s", $indent), $a), str_repeat(' ', $depth - 1));
}
- return sprintf("Array(%s)", implode(', ', $a));
+ return sprintf("[%s]", implode(', ', $a));
}
if (is_resource($value)) {