From b0ab2afceceaa9c207c655ab8c5f98a5bb17e1ad Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Tue, 3 Nov 2026 04:37:13 -0600 Subject: [PATCH 1/2] set up the injection step in the response listener Assisted-by: Claude Code --- src/DebugBar/ResponseListener.php | 8 +++++++- tests/Unit/DebugBar/ResponseListenerTest.php | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/DebugBar/ResponseListener.php b/src/DebugBar/ResponseListener.php index bc11acf..37de5f7 100644 --- a/src/DebugBar/ResponseListener.php +++ b/src/DebugBar/ResponseListener.php @@ -32,7 +32,8 @@ /** * The `application:beforeSendResponse` listener. On the event it runs the access * gate, aggregates the bar, sets the diagnostic headers, and - for an injectable - * HTML response - renders and splices the bar in. + * HTML response - renders and splices the bar in. `handle()` does the same work + * with no event. * * @phpstan-import-type request_context from DebugBarTypes * @phpstan-import-type payload from DebugBarTypes @@ -58,6 +59,11 @@ public function __invoke(EventInterface $event, mixed $source, mixed $response): return; } + $this->handle($response); + } + + public function handle(ResponseInterface $response): void + { if ($this->historyEndpoint?->matches()) { return; } diff --git a/tests/Unit/DebugBar/ResponseListenerTest.php b/tests/Unit/DebugBar/ResponseListenerTest.php index de22ca2..55b91f2 100644 --- a/tests/Unit/DebugBar/ResponseListenerTest.php +++ b/tests/Unit/DebugBar/ResponseListenerTest.php @@ -147,6 +147,18 @@ function (string $name, string $value, array $options) use (&$call): bool { $this->assertFalse(is_dir($path)); } + public function testHandleInjectsWithoutAnEvent(): void + { + $listener = $this->listener(false); + + $response = new Response(); + $response->setContent('hi'); + + $listener->handle($response); + + $this->assertStringContainsString('phalcon-debugbar-data', $response->getContent()); + } + public function testIgnoresNonResponsePayloads(): void { $listener = $this->listener(true); From e9d695af45014bf1635eb831e8dccfcef809dff6 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Tue, 3 Nov 2026 04:37:21 -0600 Subject: [PATCH 2/2] updating changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 357c267..610824a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ All notable changes to `phalcon/debugbar` are documented here. The format is bas metadata sidecars. History requires an explicit absolute writable path and is disabled by default. Storage creation is serialized and capped across browser identities, with least-recently-updated eviction. +- `ResponseListener::handle()` runs the injection step with a `ResponseInterface` and no event. The MVC listener calls it, so MVC behavior does not change. [#39](https://github.com/phalcon/debugbar/issues/39) ### Fixed