validator.html.twig 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. {% extends '@WebProfiler/Profiler/layout.html.twig' %}
  2. {% block toolbar %}
  3. {% if collector.violationsCount > 0 or collector.calls|length %}
  4. {% set status_color = collector.violationsCount ? 'red' : '' %}
  5. {% set icon %}
  6. {{ include('@WebProfiler/Icon/validator.svg') }}
  7. <span class="sf-toolbar-value">
  8. {{ collector.violationsCount ?: collector.calls|length }}
  9. </span>
  10. {% endset %}
  11. {% set text %}
  12. <div class="sf-toolbar-info-piece">
  13. <b>Validator calls</b>
  14. <span class="sf-toolbar-status">{{ collector.calls|length }}</span>
  15. </div>
  16. <div class="sf-toolbar-info-piece">
  17. <b>Number of violations</b>
  18. <span class="sf-toolbar-status {{- collector.violationsCount > 0 ? ' sf-toolbar-status-red' }}">{{ collector.violationsCount }}</span>
  19. </div>
  20. {% endset %}
  21. {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: status_color }) }}
  22. {% endif %}
  23. {% endblock %}
  24. {% block menu %}
  25. <span class="label {{- collector.violationsCount ? ' label-status-error' }} {{ collector.calls is empty ? 'disabled' }}">
  26. <span class="icon">{{ include('@WebProfiler/Icon/validator.svg') }}</span>
  27. <strong>Validator</strong>
  28. {% if collector.violationsCount > 0 %}
  29. <span class="count">
  30. <span>{{ collector.violationsCount }}</span>
  31. </span>
  32. {% endif %}
  33. </span>
  34. {% endblock %}
  35. {% block panel %}
  36. <h2>Validator calls</h2>
  37. {% for call in collector.calls %}
  38. <div class="sf-validator sf-reset">
  39. <span class="metadata">In
  40. {% set caller = call.caller %}
  41. {% if caller.line %}
  42. {% set link = caller.file|file_link(caller.line) %}
  43. {% if link %}
  44. <a href="{{ link }}" title="{{ caller.file }}">{{ caller.name }}</a>
  45. {% else %}
  46. <abbr title="{{ caller.file }}">{{ caller.name }}</abbr>
  47. {% endif %}
  48. {% else %}
  49. {{ caller.name }}
  50. {% endif %}
  51. line <a class="text-small sf-toggle" data-toggle-selector="#sf-trace-{{ loop.index0 }}">{{ caller.line }}</a> (<a class="text-small sf-toggle" data-toggle-selector="#sf-context-{{ loop.index0 }}">context</a>):
  52. </span>
  53. <div class="sf-validator-compact hidden" id="sf-trace-{{ loop.index0 }}">
  54. <div class="trace">
  55. {{ caller.file|file_excerpt(caller.line)|replace({
  56. '#DD0000': 'var(--highlight-string)',
  57. '#007700': 'var(--highlight-keyword)',
  58. '#0000BB': 'var(--highlight-default)',
  59. '#FF8000': 'var(--highlight-comment)'
  60. })|raw }}
  61. </div>
  62. </div>
  63. <div class="sf-validator-compact hidden sf-validator-context" id="sf-context-{{ loop.index0 }}">
  64. {{ profiler_dump(call.context, maxDepth=1) }}
  65. </div>
  66. {% if call.violations|length %}
  67. <table>
  68. <thead>
  69. <tr>
  70. <th>Path</th>
  71. <th>Message</th>
  72. <th>Invalid value</th>
  73. <th>Violation</th>
  74. </tr>
  75. </thead>
  76. {% for violation in call.violations %}
  77. <tr>
  78. <td>{{ violation.propertyPath }}</td>
  79. <td>{{ violation.message }}</td>
  80. <td>{{ profiler_dump(violation.seek('invalidValue')) }}</td>
  81. <td>{{ profiler_dump(violation) }}</td>
  82. </tr>
  83. {% endfor %}
  84. </table>
  85. {% else %}
  86. No violations
  87. {% endif %}
  88. </div>
  89. {% else %}
  90. <div class="empty">
  91. <p>No calls to the validator were collected during this request.</p>
  92. </div>
  93. {% endfor %}
  94. {% endblock %}