request.html.twig 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. {% extends '@WebProfiler/Profiler/layout.html.twig' %}
  2. {% block toolbar %}
  3. {% import _self as helper %}
  4. {% set request_handler %}
  5. {{ helper.set_handler(collector.controller) }}
  6. {% endset %}
  7. {% if collector.redirect %}
  8. {% set redirect_handler %}
  9. {{ helper.set_handler(collector.redirect.controller, collector.redirect.route, 'GET' != collector.redirect.method ? collector.redirect.method) }}
  10. {% endset %}
  11. {% endif %}
  12. {% if collector.forwardtoken %}
  13. {% set forward_profile = profile.childByToken(collector.forwardtoken) %}
  14. {% set forward_handler %}
  15. {{ helper.set_handler(forward_profile ? forward_profile.collector('request').controller : 'n/a') }}
  16. {% endset %}
  17. {% endif %}
  18. {% set request_status_code_color = (collector.statuscode >= 400) ? 'red' : (collector.statuscode >= 300) ? 'yellow' : 'green' %}
  19. {% set icon %}
  20. <span class="sf-toolbar-status sf-toolbar-status-{{ request_status_code_color }}">{{ collector.statuscode }}</span>
  21. {% if collector.route %}
  22. {% if collector.redirect %}{{ include('@WebProfiler/Icon/redirect.svg') }}{% endif %}
  23. {% if collector.forwardtoken %}{{ include('@WebProfiler/Icon/forward.svg') }}{% endif %}
  24. <span class="sf-toolbar-label">{{ 'GET' != collector.method ? collector.method }} @</span>
  25. <span class="sf-toolbar-value sf-toolbar-info-piece-additional">{{ collector.route }}</span>
  26. {% endif %}
  27. {% endset %}
  28. {% set text %}
  29. <div class="sf-toolbar-info-group">
  30. <div class="sf-toolbar-info-piece">
  31. <b>HTTP status</b>
  32. <span>{{ collector.statuscode }} {{ collector.statustext }}</span>
  33. </div>
  34. {% if 'GET' != collector.method -%}
  35. <div class="sf-toolbar-info-piece">
  36. <b>Method</b>
  37. <span>{{ collector.method }}</span>
  38. </div>
  39. {%- endif %}
  40. <div class="sf-toolbar-info-piece">
  41. <b>Controller</b>
  42. <span>{{ request_handler }}</span>
  43. </div>
  44. <div class="sf-toolbar-info-piece">
  45. <b>Route name</b>
  46. <span>{{ collector.route|default('n/a') }}</span>
  47. </div>
  48. <div class="sf-toolbar-info-piece">
  49. <b>Has session</b>
  50. <span>{% if collector.sessionmetadata|length %}yes{% else %}no{% endif %}</span>
  51. </div>
  52. <div class="sf-toolbar-info-piece">
  53. <b>Stateless Check</b>
  54. <span>{% if collector.statelesscheck %}yes{% else %}no{% endif %}</span>
  55. </div>
  56. </div>
  57. {% if redirect_handler is defined -%}
  58. <div class="sf-toolbar-info-group">
  59. <div class="sf-toolbar-info-piece">
  60. <b>
  61. <span class="sf-toolbar-redirection-status sf-toolbar-status-yellow">{{ collector.redirect.status_code }}</span>
  62. Redirect from
  63. </b>
  64. <span>
  65. {{ redirect_handler }}
  66. (<a href="{{ path('_profiler', { token: collector.redirect.token }) }}">{{ collector.redirect.token }}</a>)
  67. </span>
  68. </div>
  69. </div>
  70. {% endif %}
  71. {% if forward_handler is defined %}
  72. <div class="sf-toolbar-info-group">
  73. <div class="sf-toolbar-info-piece">
  74. <b>Forwarded to</b>
  75. <span>
  76. {{ forward_handler }}
  77. (<a href="{{ path('_profiler', { token: collector.forwardtoken }) }}">{{ collector.forwardtoken }}</a>)
  78. </span>
  79. </div>
  80. </div>
  81. {% endif %}
  82. {% endset %}
  83. {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url }) }}
  84. {% endblock %}
  85. {% block menu %}
  86. <span class="label">
  87. <span class="icon">{{ include('@WebProfiler/Icon/request.svg') }}</span>
  88. <strong>Request / Response</strong>
  89. </span>
  90. {% endblock %}
  91. {% block panel %}
  92. {% import _self as helper %}
  93. <h2>
  94. {{ helper.set_handler(collector.controller) }}
  95. </h2>
  96. <div class="sf-tabs">
  97. <div class="tab">
  98. <h3 class="tab-title">Request</h3>
  99. <div class="tab-content">
  100. <h3>GET Parameters</h3>
  101. {% if collector.requestquery.all is empty %}
  102. <div class="empty">
  103. <p>No GET parameters</p>
  104. </div>
  105. {% else %}
  106. {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestquery, maxDepth: 1 }, with_context = false) }}
  107. {% endif %}
  108. <h3>POST Parameters</h3>
  109. {% if collector.requestrequest.all is empty %}
  110. <div class="empty">
  111. <p>No POST parameters</p>
  112. </div>
  113. {% else %}
  114. {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestrequest, maxDepth: 1 }, with_context = false) }}
  115. {% endif %}
  116. <h4>Uploaded Files</h4>
  117. {% if collector.requestfiles is empty %}
  118. <div class="empty">
  119. <p>No files were uploaded</p>
  120. </div>
  121. {% else %}
  122. {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestfiles, maxDepth: 1 }, with_context = false) }}
  123. {% endif %}
  124. <h3>Request Attributes</h3>
  125. {% if collector.requestattributes.all is empty %}
  126. <div class="empty">
  127. <p>No attributes</p>
  128. </div>
  129. {% else %}
  130. {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestattributes }, with_context = false) }}
  131. {% endif %}
  132. <h3>Request Headers</h3>
  133. {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestheaders, labels: ['Header', 'Value'], maxDepth: 1 }, with_context = false) }}
  134. <h3>Request Content</h3>
  135. {% if collector.content == false %}
  136. <div class="empty">
  137. <p>Request content not available (it was retrieved as a resource).</p>
  138. </div>
  139. {% elseif collector.content %}
  140. <div class="sf-tabs">
  141. {% set prettyJson = collector.isJsonRequest ? collector.prettyJson : null %}
  142. {% if prettyJson is not null %}
  143. <div class="tab">
  144. <h3 class="tab-title">Pretty</h3>
  145. <div class="tab-content">
  146. <div class="card" style="max-height: 500px; overflow-y: auto;">
  147. <pre class="break-long-words">{{ prettyJson }}</pre>
  148. </div>
  149. </div>
  150. </div>
  151. {% endif %}
  152. <div class="tab">
  153. <h3 class="tab-title">Raw</h3>
  154. <div class="tab-content">
  155. <div class="card">
  156. <pre class="break-long-words">{{ collector.content }}</pre>
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. {% else %}
  162. <div class="empty">
  163. <p>No content</p>
  164. </div>
  165. {% endif %}
  166. </div>
  167. </div>
  168. <div class="tab">
  169. <h3 class="tab-title">Response</h3>
  170. <div class="tab-content">
  171. <h3>Response Headers</h3>
  172. {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.responseheaders, labels: ['Header', 'Value'], maxDepth: 1 }, with_context = false) }}
  173. </div>
  174. </div>
  175. <div class="tab {{ collector.requestcookies.all is empty and collector.responsecookies.all is empty ? 'disabled' }}">
  176. <h3 class="tab-title">Cookies</h3>
  177. <div class="tab-content">
  178. <h3>Request Cookies</h3>
  179. {% if collector.requestcookies.all is empty %}
  180. <div class="empty">
  181. <p>No request cookies</p>
  182. </div>
  183. {% else %}
  184. {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestcookies }, with_context = false) }}
  185. {% endif %}
  186. <h3>Response Cookies</h3>
  187. {% if collector.responsecookies.all is empty %}
  188. <div class="empty">
  189. <p>No response cookies</p>
  190. </div>
  191. {% else %}
  192. {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.responsecookies }, with_context = true) }}
  193. {% endif %}
  194. </div>
  195. </div>
  196. <div class="tab {{ collector.sessionmetadata is empty ? 'disabled' }}">
  197. <h3 class="tab-title">Session{% if collector.sessionusages is not empty %} <span class="badge">{{ collector.sessionusages|length }}</span>{% endif %}</h3>
  198. <div class="tab-content">
  199. <h3>Session Metadata</h3>
  200. {% if collector.sessionmetadata is empty %}
  201. <div class="empty">
  202. <p>No session metadata</p>
  203. </div>
  204. {% else %}
  205. {{ include('@WebProfiler/Profiler/table.html.twig', { data: collector.sessionmetadata }, with_context = false) }}
  206. {% endif %}
  207. <h3>Session Attributes</h3>
  208. {% if collector.sessionattributes is empty %}
  209. <div class="empty">
  210. <p>No session attributes</p>
  211. </div>
  212. {% else %}
  213. {{ include('@WebProfiler/Profiler/table.html.twig', { data: collector.sessionattributes, labels: ['Attribute', 'Value'] }, with_context = false) }}
  214. {% endif %}
  215. <h3>Session Usage</h3>
  216. <div class="metrics">
  217. <div class="metric">
  218. <span class="value">{{ collector.sessionusages|length }}</span>
  219. <span class="label">Usages</span>
  220. </div>
  221. <div class="metric">
  222. <span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.statelesscheck ? 'yes' : 'no') ~ '.svg') }}</span>
  223. <span class="label">Stateless check enabled</span>
  224. </div>
  225. </div>
  226. {% if collector.sessionusages is empty %}
  227. <div class="empty">
  228. <p>Session not used.</p>
  229. </div>
  230. {% else %}
  231. <table class="session_usages">
  232. <thead>
  233. <tr>
  234. <th class="full-width">Usage</th>
  235. </tr>
  236. </thead>
  237. <tbody>
  238. {% for key, usage in collector.sessionusages %}
  239. <tr>
  240. <td class="font-normal">
  241. {%- set link = usage.file|file_link(usage.line) %}
  242. {%- if link %}<a href="{{ link }}" title="{{ usage.name }}">{% else %}<span title="{{ usage.name }}">{% endif %}
  243. {{ usage.name }}
  244. {%- if link %}</a>{% else %}</span>{% endif %}
  245. <div class="text-small font-normal">
  246. {% set usage_id = 'session-usage-trace-' ~ key %}
  247. <a class="btn btn-link text-small sf-toggle" data-toggle-selector="#{{ usage_id }}" data-toggle-alt-content="Hide trace">Show trace</a>
  248. </div>
  249. <div id="{{ usage_id }}" class="context sf-toggle-content sf-toggle-hidden">
  250. {{ profiler_dump(usage.trace, maxDepth=2) }}
  251. </div>
  252. </td>
  253. </tr>
  254. {% endfor %}
  255. </tbody>
  256. </table>
  257. {% endif %}
  258. </div>
  259. </div>
  260. <div class="tab {{ collector.flashes is empty ? 'disabled' }}">
  261. <h3 class="tab-title">Flashes</h3>
  262. <div class="tab-content">
  263. <h3>Flashes</h3>
  264. {% if collector.flashes is empty %}
  265. <div class="empty">
  266. <p>No flash messages were created.</p>
  267. </div>
  268. {% else %}
  269. {{ include('@WebProfiler/Profiler/table.html.twig', { data: collector.flashes }, with_context = false) }}
  270. {% endif %}
  271. </div>
  272. </div>
  273. <div class="tab">
  274. <h3 class="tab-title">Server Parameters</h3>
  275. <div class="tab-content">
  276. <h3>Server Parameters</h3>
  277. <h4>Defined in .env</h4>
  278. {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.dotenvvars }, with_context = false) }}
  279. <h4>Defined as regular env variables</h4>
  280. {% set requestserver = [] %}
  281. {% for key, value in collector.requestserver|filter((_, key) => key not in collector.dotenvvars.keys) %}
  282. {% set requestserver = requestserver|merge({(key): value}) %}
  283. {% endfor %}
  284. {{ include('@WebProfiler/Profiler/table.html.twig', { data: requestserver }, with_context = false) }}
  285. </div>
  286. </div>
  287. {% if profile.parent %}
  288. <div class="tab">
  289. <h3 class="tab-title">Parent Request</h3>
  290. <div class="tab-content">
  291. <h3>
  292. <a href="{{ path('_profiler', { token: profile.parent.token }) }}">Return to parent request</a>
  293. <small>(token = {{ profile.parent.token }})</small>
  294. </h3>
  295. {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: profile.parent.getcollector('request').requestattributes }, with_context = false) }}
  296. </div>
  297. </div>
  298. {% endif %}
  299. {% if profile.children|length %}
  300. <div class="tab">
  301. <h3 class="tab-title">Sub Requests <span class="badge">{{ profile.children|length }}</span></h3>
  302. <div class="tab-content">
  303. {% for child in profile.children %}
  304. <h3>
  305. {{ helper.set_handler(child.getcollector('request').controller) }}
  306. <small>(token = <a href="{{ path('_profiler', { token: child.token }) }}">{{ child.token }}</a>)</small>
  307. </h3>
  308. {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: child.getcollector('request').requestattributes }, with_context = false) }}
  309. {% endfor %}
  310. </div>
  311. </div>
  312. {% endif %}
  313. </div>
  314. {% endblock %}
  315. {% macro set_handler(controller, route, method) %}
  316. {% if controller.class is defined -%}
  317. {%- if method|default(false) %}<span class="sf-toolbar-status sf-toolbar-redirection-method">{{ method }}</span>{% endif -%}
  318. {%- set link = controller.file|file_link(controller.line) %}
  319. {%- if link %}<a href="{{ link }}" title="{{ controller.class }}">{% else %}<span title="{{ controller.class }}">{% endif %}
  320. {%- if route|default(false) -%}
  321. @{{ route }}
  322. {%- else -%}
  323. {{- controller.class|abbr_class|striptags -}}
  324. {{- controller.method ? ' :: ' ~ controller.method -}}
  325. {%- endif -%}
  326. {%- if link %}</a>{% else %}</span>{% endif %}
  327. {%- else -%}
  328. <span>{{ route|default(controller) }}</span>
  329. {%- endif %}
  330. {% endmacro %}