-
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
Showing
3 changed files
with
104 additions
and
1 deletion.
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 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 | ||
{ | ||
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'; | ||
} | ||
} |
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,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) }} | ||
</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