Permalink
Browse files

feature #26946 [WebProfilerBundle] Display uploaded files in the prof…

…iler (javiereguiluz)

This PR was squashed before being merged into the 4.2-dev branch (closes #26946).

Discussion
----------

[WebProfilerBundle] Display uploaded files in the profiler

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #26926
| License       | MIT
| Doc PR        | -

![profiler_files](https://user-images.githubusercontent.com/73419/38807087-ac1e9bac-417b-11e8-99e0-317b437c986e.png)

Note: I wanted to use the VarDumper to display the table information (as we do in the rest of tables) but I had lots of problems and I just wanted to create a proof of concept for the feature to see if we like it.

Commits
-------

3f6f75b [WebProfilerBundle] Display uploaded files in the profiler
  • Loading branch information...
fabpot committed Jun 25, 2018
2 parents 21a3439 + 3f6f75b commit 2b9c142f07b7dbc11d4d392b77629fa91a5dcb41
@@ -131,6 +131,33 @@
{{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestrequest, maxDepth: 1 }, with_context = false) }}
{% endif %}
<h3>Uploaded files</h3>
{% if collector.requestfiles is empty %}
<div class="empty">
<p>No files were uploaded</p>
</div>
{% else %}
<table>
<thead>
<tr>
<th scope="col">File Name</th>
<th scope="col">MIME Type</th>
<th scope="col text-right">Size (bytes)</th>
</tr>
</thead>
<tbody>
{% for file in collector.requestfiles %}
<tr>
<td>{{ file.name }}</td>
<td>{{ file.mimetype }}</td>
<td class="text-right">{{ file.size|number_format }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
<h3>Request Attributes</h3>
{% if collector.requestattributes.all is empty %}
@@ -57,6 +57,17 @@ public function collect(Request $request, Response $response, \Exception $except
$content = false;
}
$requestFiles = array();
foreach ($request->files->all() as $files) {
foreach ($files as $fileName => $fileData) {
$requestFiles[] = array(
'name' => $fileData->getClientOriginalName(),
'mimetype' => $fileData->getMimeType(),
'size' => $fileData->getSize(),
);
}
}
$sessionMetadata = array();
$sessionAttributes = array();
$session = null;
@@ -95,6 +106,7 @@ public function collect(Request $request, Response $response, \Exception $except
'status_code' => $statusCode,
'request_query' => $request->query->all(),
'request_request' => $request->request->all(),
'request_files' => $requestFiles,
'request_headers' => $request->headers->all(),
'request_server' => $request->server->all(),
'request_cookies' => $request->cookies->all(),
@@ -195,6 +207,11 @@ public function getRequestQuery()
return new ParameterBag($this->data['request_query']->getValue());
}
public function getRequestFiles()
{
return $this->data['request_files']->getValue(true);
}
public function getRequestHeaders()
{
return new ParameterBag($this->data['request_headers']->getValue());

0 comments on commit 2b9c142

Please sign in to comment.