-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mathieu Haverkamp
committed
Aug 15, 2024
1 parent
dd0e608
commit 1fb5da6
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 TestDataCollector 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 | ||
{ | ||
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/test.html.twig'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{% extends '@WebProfiler/Profiler/layout.html.twig' %} | ||
|
||
{% block toolbar %} | ||
{% set icon %} | ||
{% import 'stuff/_test.html.twig' as cavia %} | ||
{# this is the content displayed as a panel in the toolbar #} | ||
<span class="sf-toolbar-value">{{ cavia.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) }} | ||
</tr> | ||
</table> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% macro cavia(cavia) %} | ||
I AM A {{ cavia }} MACRO | ||
{% endmacro cavia %} |