diff --git a/webprofiler/src/DataCollector/RequestDataCollector.php b/webprofiler/src/DataCollector/RequestDataCollector.php index dc15848fd9d9223a23e4e6b99cb502050a5c0fd4..a23d5407585894e628bb03ed93df1c47e2860705 100644 --- a/webprofiler/src/DataCollector/RequestDataCollector.php +++ b/webprofiler/src/DataCollector/RequestDataCollector.php @@ -81,4 +81,33 @@ class RequestDataCollector extends BaseRequestDataCollector implements DrupalDat public function getIcon() { return 'iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAQAAADYBBcfAAACvElEQVR42tVTbUhTYRTerDCnKVoUUr/KCZmypA9Koet0bXNLJ5XazDJ/WFaCUY0pExRZXxYiJgsxWWjkaL+yK+po1gjyR2QfmqWxtBmaBtqWGnabT++c11Fu4l/P4VzOPc95zoHznsNZodIbLDdRcKnc1Bu8DAK45ZsOnykQNMopsNooLxCknb0cDq5vml9FtHiIgpBR0R6iihYyFMTDt2Lg56ObPkI6TMGXSof1EV67IqCwisJSWliFAG/E0CfFIiebdNypcxi/1zgyFiIiZ3sJQr0RQx5frLa6k7SOKRo3oMFNR5t62h2rttKXEOKFqDCxtXNmmBokO2KKTlp3IdWuT2dYRNGKwEXEBCcL172G5FG0aIxC0kR9PBTVH1kkwQn+IqJnCE33EalVzT9GJQS1tAdD3CKicJYFrxqx7W2ejCEdZy1FiC5tZxHhLJKOZaRdQJAyV/YAvDliySALHxmxR4Hqe2iwvaOR/CEuZYJFSgYhVbZRkA8KGdEktrqnqra90NndCdkt77fjIHIhexOrfO6O3bbbOj/rqu5IptgyR3sU93QbOYhquZK4MCDp0Ina/PLsu5JvbCTRaapUdUmIV/RzoMdsk/0hWRNdAvKOmvqlN0drsJbJf1P4YsQ5lGrJeuosiOUgbOC8cto3LfOXTdVd7BqZsQKbse+0jUL6WPcesqs4MNSUTQAxGjwFiC8m3yzmqwHJBWYKBJ9WNqW/dHkpU/osch1Yj5RJfXPfSEe/2UPsN490NPfZG5CKyJmcV5ayHyzy7BMqsXfuHhGK/cjAIeSpR92gehR55D8TcQhDEKJwytBJ4fr4NULvrEM8NszfJPyxDoHYAQ1oPCWmIX4gifmDS/DV2DKeb25FHWr76yEG7/9L4YFPeiQQ4/8LkgJ8Et+NncTCsYqzXAEXa7CWdPZzGWdlyV+vST0JanfPvwAAAABJRU5ErkJggg=='; } + + /** + * @return array|string + */ + public function getData() { + // Drupal 8.5+ uses Symfony 3.4.x that changes the way the Request data are + // collected. Data is altered with \Symfony\Component\HttpKernel\DataCollector\DataCollector::cloneVar. + // The stored data (of type \Symfony\Component\VarDumper\Cloner\Data) is + // suitable to be converted to a string by a Dumper (\Symfony\Component\VarDumper\Dumper\DataDumperInterface). + // In our implementation however we need that data as an array, to be later + // converted in a json response by a REST endpoint. We need to refactor the + // whole way Web Profiler works to allow that. At the moment we just + // retrieve the raw Data value and do some string manipulation to clean the + // output a bit. + + $data = $this->data->getValue(TRUE); + unset($data['request_attributes']['_route_params']); + unset($data['request_attributes']['_access_result']); + + $route_object = []; + foreach($data['request_attributes']['_route_object'] as $key => $result) { + $key = str_replace("\0", '', $key); + $key = str_replace('Symfony\Component\Routing\Route', 'Symfony\Component\Routing\Route::', $key); + $route_object[$key] = $result; + } + $data['request_attributes']['_route_object'] = $route_object; + + return $data; + } } diff --git a/webprofiler/templates/Collector/request.html.twig b/webprofiler/templates/Collector/request.html.twig index 4a1e1e308f9ae4017f882926e7ea122ad025ab0d..b57a85419abeba9e1c9f4f248902e1c67306af14 100644 --- a/webprofiler/templates/Collector/request.html.twig +++ b/webprofiler/templates/Collector/request.html.twig @@ -46,9 +46,10 @@ <% if (!_.isEmpty(data.request_query)) { %>
+

GET parameters

- + @@ -65,9 +66,10 @@ <% if (!_.isEmpty(data.request_request)) { %>
+

POST parameters

{{ 'GET Parameters'|t }}{{ 'Name'|t }} {{ 'Value'|t }}
- + @@ -83,18 +85,20 @@ <% } %>
+

Request attributes

{{ 'POST Parameters'|t }}{{ 'Name'|t }} {{ 'Value'|t }}
- + <% _.each( data.request_attributes, function( item, key ){ %> - <% if(key == '_controller') { %> + <% } else if(key == '_form') { %> + <% } else { %> <% } %> @@ -106,9 +110,10 @@ <% if (!_.isEmpty(data.request_cookies)) { %>
+

Cookies

{{ 'Attributes'|t }}{{ 'Name'|t }} {{ 'Value'|t }}
<%- key %><%= Drupal.webprofiler.helpers.classLink(data.controller) %><%= Drupal.webprofiler.helpers.classLink(data.controller) %><%= Drupal.webprofiler.helpers.frm(item) %>
- + @@ -124,9 +129,10 @@ <% } %>
+

Request headers

{{ 'Cookies'|t }}{{ 'Name'|t }} {{ 'Value'|t }}
- + @@ -142,16 +148,18 @@ <% if (!_.isEmpty(data.content)) { %>
+

Raw content

<%- data.content %>
<% } %> <% if (!_.isEmpty(data.access_check)) { %>
+

Access check

{{ 'Request headers'|t }}{{ 'Name'|t }} {{ 'Value'|t }}
- + <% _.each(data.access_check, function(items, key){ %> @@ -170,9 +178,10 @@ <% } %>
+

Server Parameters

{{ 'Path'|t }}{{ 'Access check'|t }}{{ 'Service'|t }}
- + @@ -187,9 +196,10 @@
+

Response headers

{{ 'Server Parameters'|t }}{{ 'Name'|t }} {{ 'Value'|t }}
- +
{{ 'Response headers'|t }}{{ 'Name'|t }} {{ 'Value'|t }}