8000 [WebProfilerBundle] Better handling of queries with an empty result · umpirski/symfony@f49a30c · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit f49a30c

Browse files
committed
[WebProfilerBundle] Better handling of queries with an empty result
1 parent ed09566 commit f49a30c

File tree

3 files changed

+32
-23
lines changed

3 files changed

+32
-23
lines changed

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public function searchAction()
235235

236236
$tokens = $profiler->find($ip, $url, $limit);
237237

238-
return new RedirectResponse($this->container->get('router')->generate('_profiler_search_results', array('token' => $tokens ? $tokens[0]['token'] : '')));
238+
return new RedirectResponse($this->container->get('router')->generate('_profiler_search_results', array('token' => $tokens ? $tokens[0]['token'] : 'empty')));
239239
}
240240

241241
protected function getTemplateNames($profiler)

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
<div id="content">
88
{% include 'WebProfilerBundle:Profiler:header.html.twig' only %}
99

10-
<div class="resume">
11-
<p>
12-
<strong><a href="{{ profiler.url }}">{{ profiler.url }}</a></strong>
13-
<span class="date">
14-
<strong>by {{ profiler.ip }}</strong> at <strong>{{ profiler.time|date('r') }}</strong>
15-
</span>
16-
</p>
17-
</div>
10+
{% if not profiler.isempty %}
11+
<div class="resume">
12+
<p>
13+
<strong><a href="{{ profiler.url }}">{{ profiler.url }}</a></strong>
14+
<span class="date">
15+
<strong>by {{ profiler.ip }}</strong> at <strong>{{ profiler.time|date('r') }}</strong>
16+
</span>
17+
</p>
18+
</div>
19+
{% endif %}
1820

1921
<div class="main">
2022

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/results.html.twig

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,27 @@
33
{% block panel %}
44
<h2>Search Results</h2>
55

6-
<table>
7-
<tr>
8-
<th>Token</th>
9-
<th>IP</th>
10-
<th>URL</th>
11-
<th>Time</th>
12-
</tr>
13-
{% for elements in tokens %}
6+
{% if tokens %}
7+
<table>
148
<tr>
15-
<td><a href="{{ path('_profiler', { 'token': elements.token }) }}">{{ elements.token }}</a></td>
16-
<td>{{ elements.ip }}</td>
17-
<td>{{ elements.url }}</td>
18-
<td>{{ elements.time|date('r') }}</td>
9+
<th>Token</th>
10+
<th>IP</th>
11+
<th>URL</th>
12+
<th>Time</th>
1913
</tr>
20-
{% endfor %}
21-
</table>
14+
{% for elements in tokens %}
15+
<tr>
16+
<td><a href="{{ path('_profiler', { 'token': elements.token }) }}">{{ elements.token }}</a></td>
17+
<td>{{ elements.ip }}</td>
18+
<td>{{ elements.url }}</td>
19+
<td>{{ elements.time|date('r') }}</td>
20+
</tr>
21+
{% endfor %}
22+
</table>
23+
{% else %}
24+
<p>
25+
<em>The query returned no result.</em>
26+
</p>
27+
{% endif %}
28+
2229
{% endblock %}

0 commit comments

Comments
 (0)
0