Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/DI/EventDispatcherExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function getConfigSchema(): Schema
'lazy' => Expect::bool(true),
'autoload' => Expect::bool(true),
'debug' => Expect::bool(false),
'debugContentDepth' => Expect::int(2),
'loggers' => Expect::arrayOf(Expect::type(Statement::class)),
]);
}
Expand Down Expand Up @@ -92,7 +93,13 @@ public function afterCompile(ClassType $class): void
// @phpstan-ignore-next-line
$builder->formatPhp('?->addPanel(?);', [
$builder->getDefinitionByType(Bar::class),
new Statement(EventPanel::class, [$builder->getDefinition($this->prefix('dispatcher.tracy'))]),
new Statement(
EventPanel::class,
[
$builder->getDefinition($this->prefix('dispatcher.tracy')),
$config->debugContentDepth,
]
),
])
);
}
Expand Down
5 changes: 4 additions & 1 deletion src/Tracy/EventPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ class EventPanel implements IBarPanel
{

private TracyDispatcher $dispatcher;
private int $debugContentDepth;

public function __construct(TracyDispatcher $dispatcher)
public function __construct(TracyDispatcher $dispatcher, int $debugContentDepth)
{
$this->dispatcher = $dispatcher;
$this->debugContentDepth = $debugContentDepth;
}

/**
Expand Down Expand Up @@ -40,6 +42,7 @@ public function getPanel(): string
$totalTime = $this->countTotalTime(); // @phpcs:ignore
$events = $this->dispatcher->getEvents(); // @phpcs:ignore
$listeners = $this->dispatcher->getListeners();
$debugContentDepth = $this->debugContentDepth;
ksort($listeners);
ob_start();
require __DIR__ . '/templates/panel.phtml';
Expand Down
11 changes: 6 additions & 5 deletions src/Tracy/templates/panel.phtml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php
/** @var EventInfo[] $events */
/** @var int $debugContentDepth */
/** @var EventTrace[] $events */
/** @var array<string,callable> $listeners */
/** @var int $handledCount */

/** @var float $totalTime */

use Contributte\EventDispatcher\Diagnostics\EventInfo;
use Contributte\EventDispatcher\Diagnostics\EventTrace;
use Tracy\Dumper;
?>
<style>
Expand Down Expand Up @@ -44,7 +45,7 @@ use Tracy\Dumper;
</td>
<td><?= $e->handled ? 'yes' : 'no' ?></td>
<td>
<?= Dumper::toHtml($e->event, [Dumper::COLLAPSE => true]); ?>
<?= Dumper::toHtml($e->event, [Dumper::COLLAPSE => true, Dumper::DEPTH => $debugContentDepth]); ?>
</td>
</tr>
<?php endforeach; ?>
Expand Down Expand Up @@ -74,7 +75,7 @@ use Tracy\Dumper;
} else if ($handler instanceof \Contributte\EventDispatcher\LazyListener) {
echo $handler->toString();
} else {
echo Dumper::toHtml($handler);
echo Dumper::toHtml($handler, [Dumper::DEPTH => $debugContentDepth]);
}
?>
</td>
Expand All @@ -84,7 +85,7 @@ use Tracy\Dumper;
</table>

<div style="margin-top: var(--tracy-space);">
<?= Dumper::toHtml($listeners, [Dumper::COLLAPSE => true]); ?>
<?= Dumper::toHtml($listeners, [Dumper::COLLAPSE => true, Dumper::DEPTH => $debugContentDepth + 2]); ?>
</div>
</div>
</div>
Expand Down