Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[WebProfilerBundle] Misc code updates in controller and templates #48759

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

Merged
merged 1 commit into from
Dec 22, 2022
Merged
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 @@ -172,38 +172,18 @@ public function searchBarAction(Request $request): Response

$this->cspHandler?->disableCsp();

if (!$request->hasSession()) {
$ip =
$method =
$statusCode =
$url =
$start =
$end =
$limit =
$token = null;
} else {
$session = $request->getSession();

$ip = $request->query->get('ip', $session->get('_profiler_search_ip'));
$method = $request->query->get('method', $session->get('_profiler_search_method'));
$statusCode = $request->query->get('status_code', $session->get('_profiler_search_status_code'));
$url = $request->query->get('url', $session->get('_profiler_search_url'));
$start = $request->query->get('start', $session->get('_profiler_search_start'));
$end = $request->query->get('end', $session->get('_profiler_search_end'));
$limit = $request->query->get('limit', $session->get('_profiler_search_limit'));
$token = $request->query->get('token', $session->get('_profiler_search_token'));
}
$session = $request->hasSession() ? $request->getSession() : null;

return new Response(
$this->twig->render('@WebProfiler/Profiler/search.html.twig', [
'token' => $token,
'ip' => $ip,
'method' => $method,
'status_code' => $statusCode,
'url' => $url,
'start' => $start,
'end' => $end,
'limit' => $limit,
'token' => $request->query->get('token', $session?->get('_profiler_search_token')),
'ip' => $request->query->get('ip', $session?->get('_profiler_search_ip')),
'method' => $request->query->get('method', $session?->get('_profiler_search_method')),
'status_code' => $request->query->get('status_code', $session?->get('_profiler_search_status_code')),
'url' => $request->query->get('url', $session?->get('_profiler_search_url')),
'start' => $request->query->get('start', $session?->get('_profiler_search_start')),
'end' => $request->query->get('end', $session?->get('_profiler_search_end')),
'limit' => $request->query->get('limit', $session?->get('_profiler_search_limit')),
'request' => $request,
'render_hidden_by_default' => false,
]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% import _self as helper %}

{% block menu %}
<span class="label">
<span class="icon">{{ source('@WebProfiler/Icon/event.svg') }}</span>
Expand All @@ -22,7 +20,7 @@
<h3 class="tab-title">Called Listeners <span class="badge">{{ collector.calledlisteners|length }}</span></h3>

<div class="tab-content">
{{ helper.render_table(collector.calledlisteners) }}
{{ _self.render_table(collector.calledlisteners) }}
</div>
</div>

Expand All @@ -41,7 +39,7 @@
</p>
</div>
{% else %}
{{ helper.render_table(collector.notcalledlisteners) }}
{{ _self.render_table(collector.notcalledlisteners) }}
{% endif %}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% from _self import form_tree_entry, form_tree_details %}

{% block toolbar %}
{% if collector.data.nb_errors > 0 or collector.data.forms|length %}
{% set status_color = collector.data.nb_errors ? 'red' %}
Expand Down Expand Up @@ -180,14 +178,14 @@
<div id="tree-menu" class="tree">
<ul>
{% for formName, formData in collector.data.forms %}
{{ form_tree_entry(formName, formData, true) }}
{{ _self.form_tree_entry(formName, formData, true) }}
{% endfor %}
</ul>
</div>

<div id="tree-details-container">
{% for formName, formData in collector.data.forms %}
{{ form_tree_details(formName, formData, collector.data.forms_by_hash, loop.first) }}
{{ _self.form_tree_details(formName, formData, collector.data.forms_by_hash, loop.first) }}
{% endfor %}
</div>
{% else %}
Expand Down Expand Up @@ -416,7 +414,6 @@
{% endblock %}

{% macro form_tree_entry(name, data, is_root) %}
{% import _self as tree %}
{% set has_error = data.errors is defined and data.errors|length > 0 %}
<li>
<div class="tree-inner" data-tab-target-id="{{ data.id }}-details" title="{{ name|default('(no name)') }}">
Expand All @@ -438,15 +435,14 @@
{% if data.children is not empty %}
<ul id="{{ data.id }}-children" {% if not is_root and not data.has_children_error|default(false) %}class="hidden"{% endif %}>
{% for childName, childData in data.children %}
{{ tree.form_tree_entry(childName, childData, false) }}
{{ _self.form_tree_entry(childName, childData, false) }}
{% endfor %}
</ul>
{% endif %}
</li>
{% endmacro %}

{% macro form_tree_details(name, data, forms_by_hash, show) %}
{% import _self as tree %}
<div class="tree-details{% if not show|default(false) %} hidden{% endif %}" {% if data.id is defined %}id="{{ data.id }}-details"{% endif %}>
<h2>{{ name|default('(no name)') }}</h2>
{% if data.type_class is defined %}
Expand Down Expand Up @@ -509,7 +505,7 @@
</div>

{% for childName, childData in data.children %}
{{ tree.form_tree_details(childName, childData, forms_by_hash) }}
{{ _self.form_tree_details(childName, childData, forms_by_hash) }}
{% endfor %}
{% endmacro %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% import _self as helper %}

{% block toolbar %}
{% if collector.counterrors or collector.countdeprecations or collector.countwarnings %}
{% set icon %}
Expand Down Expand Up @@ -163,7 +161,7 @@
</td>

<td class="font-normal">
{{ helper.render_log_message('debug', loop.index, log) }}
{{ _self.render_log_message('debug', loop.index, log) }}
</td>
</tr>
{% endfor %}
Expand All @@ -177,11 +175,7 @@
<script>Sfjs.initializeLogsTable();</script>
{% endif %}

{% set compilerLogTotal = 0 %}
{% for logs in collector.compilerLogs %}
{% set compilerLogTotal = compilerLogTotal + logs|length %}
{% endfor %}

{% set compilerLogTotal = collector.compilerLogs|reduce((total, logs) => total + logs|length, 0) %}
<details class="container-compilation-logs">
<summary>
<h4>Container Compilation Logs <span class="text-muted">({{ compilerLogTotal }})</span></h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
{% if message.attachments %}
<div class="card-block">
{% set num_of_attachments = message.attachments|length %}
{% set total_attachments_size_in_bytes = message.attachments|reduce((total_size, attachment) => total_size + attachment.body|length) %}
{% set total_attachments_size_in_bytes = message.attachments|reduce((total_size, attachment) => total_size + attachment.body|length, 0) %}
<p class="mailer-message-attachments-title">
{{ source('@WebProfiler/Icon/attachment.svg') }}
Attachments <span>({{ num_of_attachments }} file{{ num_of_attachments > 1 ? 's' }} / {{ _self.render_file_size_humanized(total_attachments_size_in_bytes) }})</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% import _self as helper %}

{% block toolbar %}
{% if collector.messages|length > 0 %}
{% set status_color = collector.exceptionsCount ? 'red' %}
Expand Down Expand Up @@ -61,8 +59,6 @@
{% endblock %}

{% block panel %}
{% import _self as helper %}

<h2>Messages</h2>

{% if collector.messages is empty %}
Expand All @@ -71,7 +67,7 @@
</div>
{% elseif 1 == collector.buses|length %}
<p class="text-muted">Ordered list of dispatched messages across all your buses</p>
{{ helper.render_bus_messages(collector.messages, true) }}
{{ _self.render_bus_messages(collector.messages, true) }}
{% else %}
<div class="sf-tabs message-bus">
<div class="tab">
Expand All @@ -81,7 +77,7 @@

<div class="tab-content">
<p class="text-muted">Ordered list of dispatched messages across all your buses</p>
{{ helper.render_bus_messages(messages, true) }}
{{ _self.render_bus_messages(messages, true) }}
</div>
</div>

Expand All @@ -93,7 +89,7 @@

<div class="tab-content">
<p class="text-muted">Ordered list of messages dispatched on the <code>{{ bus }}</code> bus</p>
{{ helper.render_bus_messages(messages) }}
{{ _self.render_bus_messages(messages) }}
</div>
</div>
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% import _self as helper %}

{% block toolbar %}
{% if collector.handledCount > 0 %}
{% set icon %}
Expand Down Expand Up @@ -89,14 +87,14 @@
</div>

<div class="sf-tabs">
{{ helper.render_serialize_tab(collector.data, true) }}
{{ helper.render_serialize_tab(collector.data, false) }}
{{ _self.render_serialize_tab(collector.data, true) }}
{{ _self.render_serialize_tab(collector.data, false) }}

{{ helper.render_normalize_tab(collector.data, true) }}
{{ helper.render_normalize_tab(collector.data, false) }}
{{ _self.render_normalize_tab(collector.data, true) }}
{{ _self.render_normalize_tab(collector.data, false) }}

{{ helper.render_encode_tab(collector.data, true) }}
{{ helper.render_encode_tab(collector.data, false) }}
{{ _self.render_encode_tab(collector.data, true) }}
{{ _self.render_encode_tab(collector.data, false) }}
</div>
{% endif %}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% import _self as helper %}

{% block toolbar %}
{% set has_time_events = collector.events|length > 0 %}
{% set total_time = has_time_events ? '%.0f'|format(collector.duration) : 'n/a' %}
Expand Down Expand Up @@ -70,14 +68,9 @@
<span class="label">Sub-Request{{ profile.children|length > 1 ? 's' }}</span>
</div>

{% if has_time_events %}
{% set subrequests_time = 0 %}
{% for child in profile.children %}
{% set subrequests_time = subrequests_time + child.getcollector('time').events.__section__.duration %}
{% endfor %}
{% else %}
{% set subrequests_time = 'n/a' %}
{% endif %}
{% set subrequests_time = has_time_events
? profile.children|reduce((total, child) => total + child.getcollector('time').events.__section__.duration, 0)
: 'n/a' %}

<div class="metric">
<span class="value">{{ subrequests_time }} <span class="unit">ms</span></span>
Expand Down Expand Up @@ -124,7 +117,7 @@
</h3>
{% endif %}

{{ helper.display_timeline(token, collector.events, collector.events.__section__.origin) }}
{{ _self.display_timeline(token, collector.events, collector.events.__section__.origin) }}

{% if profile.children|length %}
<p class="help">Note: sections with a striped background correspond to sub-requests.</p>
Expand All @@ -138,7 +131,7 @@
<small>{{ events.__section__.duration }} ms</small>
</h4>

{{ helper.display_timeline(child.token, events, collector.events.__section__.origin) }}
{{ _self.display_timeline(child.token, events, collector.events.__section__.origin) }}
{% endfor %}
{% endif %}

Expand All @@ -159,12 +152,11 @@

{% macro dump_request_data(token, events, origin) %}
{% autoescape 'js' %}
{% from _self import dump_events %}
{
id: "{{ token }}",
left: {{ "%F"|format(events.__section__.origin - origin) }},
end: "{{ '%F'|format(events.__section__.endtime) }}",
events: [ {{ dump_events(events) }} ],
events: [ {{ _self.dump_events(events) }} ],
}
{% endautoescape %}
{% endmacro %}
Expand Down Expand Up @@ -199,7 +191,6 @@
{% endmacro %}

{% macro display_timeline(token, events, origin) %}
{% import _self as helper %}
<div class="sf-profiler-timeline">
<div id="legend-{{ token }}" class="legends"></div>
<svg id="timeline-{{ token }}" class="timeline-graph"></svg>
Expand All @@ -212,7 +203,7 @@
new SvgRenderer(document.getElementById('timeline-{{ token }}')),
new Legend(document.getElementById('legend-{{ token }}'), theme),
document.getElementById('threshold'),
{{ helper.dump_request_data(token, events, origin) }}
{{ _self.dump_request_data(token, events, origin) }}
);
});
{% endautoescape %}</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% import _self as helper %}

{% block toolbar %}
{% if collector.messages|length %}
{% set icon %}
Expand Down Expand Up @@ -105,7 +103,7 @@
</div>
{% else %}
{% block defined_messages %}
{{ helper.render_table(messages_defined) }}
{{ _self.render_table(messages_defined) }}
{% endblock %}
{% endif %}
</div>
Expand All @@ -126,7 +124,7 @@
</div>
{% else %}
{% block fallback_messages %}
{{ helper.render_table(messages_fallback, true) }}
{{ _self.render_table(messages_fallback, true) }}
{% endblock %}
{% endif %}
</div>
Expand All @@ -148,7 +146,7 @@
</div>
{% else %}
{% block missing_messages %}
{{ helper.render_table(messages_missing) }}
{{ _self.render_table(messages_missing) }}
{% endblock %}
{% endif %}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
{%- endif -%}
{% endmacro %}

{% import _self as helper %}

{% block summary %}
<div class="status">
<h2>Profile Search</h2>
Expand Down Expand Up @@ -41,14 +39,14 @@
<span class="label {{ css_class }}">{{ result.status_code|default('n/a') }}</span>
</td>
<td>
<span class="nowrap">{{ result.ip }} {{ helper.profile_search_filter(request, result, 'ip') }}</span>
<span class="nowrap">{{ result.ip }} {{ _self.profile_search_filter(request, result, 'ip') }}</span>
</td>
<td>
<span class="nowrap">{{ result.method }} {{ helper.profile_search_filter(request, result, 'method') }}</span>
<span class="nowrap">{{ result.method }} {{ _self.profile_search_filter(request, result, 'method') }}</span>
</td>
<td class="break-long-words">
{{ result.url }}
{{ helper.profile_search_filter(request, result, 'url') }}
{{ _self.profile_search_filter(request, result, 'url') }}
</td>
<td class="text-small">
<span class="nowrap">{{ result.time|date('d-M-Y') }}</span>
Expand Down