Skip to content

Commit

Permalink
Add broken data collector template
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Haverkamp authored and cavias committed Aug 15, 2024
1 parent 1fb5da6 commit 8188b36
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 1 deletion.
41 changes: 41 additions & 0 deletions src/DataCollector/AnotherDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\DataCollector;

use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\VarDumper\Cloner\Data;

class AnotherDataCollector extends AbstractDataCollector
{

public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
{
$this->data = [
'method' => $request->getMethod(),
'acceptable_content_types' => $request->getAcceptableContentTypes(),
];
}

public function getMethod(): string
{
return $this->data['method'];
}

public function getAcceptableContentTypes(): array

Check failure on line 26 in src/DataCollector/AnotherDataCollector.php

View workflow job for this annotation

GitHub Actions / Linters (8.2)

Method App\DataCollector\AnotherDataCollector::getAcceptableContentTypes() return type has no value type specified in iterable type array.
{
return $this->data['acceptable_content_types'];
}

public function getSomeObject(): Data
{
// use the cloneVar() method to dump collected data in the profiler
return $this->cloneVar($this->data['method']);
}

public static function getTemplate(): ?string
{
return 'collector/another.html.twig';
}
}
61 changes: 61 additions & 0 deletions templates/collector/another.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{# Now this breaks stuff #}
{% from 'stuff/_test.html.twig' import cavia %}

{% block toolbar %}
{% set icon %}
{# this is the content displayed as
a panel in the toolbar #}

{# Especially here #}
<span class="sf-toolbar-value">{{ cavia('cavia') }}</span>
{% endset %}

{% set text %}
{# this is the content displayed when hovering the mouse over
the toolbar panel #}
<div class="sf-toolbar-info-piece">
<b>Method</b>
<span>{{ collector.method }}</span>
</div>

<div class="sf-toolbar-info-piece">
<b>Accepted content type</b>
<span>{{ collector.acceptableContentTypes|join(', ') }}</span>
</div>
{% endset %}

{# the 'link' value set to 'false' means that this panel doesn't
show a section in the web profiler #}
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: false }) }}
{% endblock %}

{% block menu %}
{# This left-hand menu appears when using the full-screen profiler. #}
<span class="label">
<span class="icon"><img src="..." alt=""/></span>
<strong>Cavia</strong>
</span>
{% endblock %}

{% block panel %}
{# Optional, for showing the most details. #}
<h2>Acceptable Content Types</h2>
<table>
<tr>
<th>Content Type</th>
</tr>

{% for type in collector.acceptableContentTypes %}
<tr>
<td>{{ type }}</td>
</tr>
{% endfor %}

{# use the profiler_dump() function to render the contents of dumped objects #}
<tr>
{{ profiler_dump(collector.someObject) }}

Check failure on line 58 in templates/collector/another.html.twig

View workflow job for this annotation

GitHub Actions / Linters (8.2)

Unknown "profiler_dump" function.
</tr>
</table>
{% endblock %}
3 changes: 2 additions & 1 deletion templates/default/homepage.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
{{ render_language_selector(true) }}
</div>

<h1>{{ cavia('asdasdasdasdasd') }} import</h1>

<div class="row">
<div class="col-sm">
<div class="jumbotron">
<p>
{{ 'help.browse_app'|trans|raw }}
</p>
{{ cavia('asdasdasdasdasd') }}
<p>
<a class="btn btn-primary btn-lg" href="{{ path('blog_index') }}">
<i class="fa fa-users" aria-hidden="true"></i> {{ 'action.browse_app'|trans }}
Expand Down

0 comments on commit 8188b36

Please sign in to comment.