Skip to content

Commit

Permalink
feat: Web profiler bundle integration.
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Feb 5, 2024
1 parent 0162a59 commit c3849c0
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 0.6.2

* feat: Data collector.
* feat: Web profiler bundle integration.

## 0.6.1

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"dave-liddament/php-language-extensions": "^0.6.0",
"dave-liddament/phpstan-php-language-extensions": "^0.5.0",
"brick/money": "^0.9.0",
"tomasvotruba/unused-public": "^0.3.5"
"tomasvotruba/unused-public": "^0.3.5",
"twig/twig": "^2.12|^3.0"
},
"autoload": {
"psr-4": {
Expand Down
11 changes: 8 additions & 3 deletions src/Debug/MapperDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
namespace Rekalogika\Mapper\Debug;

use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface;
use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\PropertyInfo\Type;

final class MapperDataCollector extends DataCollector
final class MapperDataCollector extends AbstractDataCollector
{
public function getName()
public function getName(): string
{
return 'rekalogika_mapper';
}
Expand Down Expand Up @@ -70,4 +70,9 @@ public function getMappings(): array
/** @var array<int,TraceData> */
return $this->data['mappings'];
}

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

{% block menu %}
<span class="label {{ not collector.mappings|length ? 'disabled' }}">
<span class="icon">{{ source('@RekalogikaMapper/map.svg') }}</span>
<strong>Mapper</strong>
</span>
{% endblock %}

{% block panel %}
<h2>Mapper</h2>
<div class="sf-rekalogika_mapper sf-reset">
<table>
<tr>
<th>Path</th>
<th>Source</th>
<th>Target</th>
<th>Transformer</th>
</tr>

{% for tracedata in collector.mappings %}
<tr>
<td>{{ tracedata.path }}</td>
<td>{{ profiler_dump(tracedata.source) }}</td>
<td>{{ profiler_dump(tracedata.target) }}</td>
<td>{{ tracedata.transformerClass|abbr_class }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endblock %}
1 change: 1 addition & 0 deletions templates/map.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions tests/Common/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
use Rekalogika\Mapper\Transformer\TraversableToArrayAccessTransformer;
use Rekalogika\Mapper\Transformer\TraversableToTraversableTransformer;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
Expand All @@ -54,6 +56,7 @@ public function registerBundles(): iterable
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(function (ContainerBuilder $container) {
$container->setParameter('kernel.secret', 'test');
$container->loadFromExtension('framework', [
'http_method_override' => false,
'handle_all_throwables' => true,
Expand Down

0 comments on commit c3849c0

Please sign in to comment.