-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[WebProfilerBundle] add debugbar on StreamedResponse
#58789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 7.4
Are you sure you want to change the base?
Changes from 1 commit
c1e7be0
70b2ba6
6f0f764
677f95c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\WebProfilerBundle\Tests\EventListener; | ||
|
||
use Symfony\Component\HttpFoundation\StreamedResponse; | ||
|
||
class MockedStreamedResponse extends StreamedResponse | ||
{ | ||
public function getContent(): string|false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would not override the Instead, I would suggest writing a separate test covering the injection of the toolbar in a streamed response, which would perform this output buffering in the test (using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right and indeed I missed a bug on StreamedResponse here. Let me know if it's ok for you. |
||
{ | ||
ob_start(); | ||
($this->callback)(); | ||
$content = ob_get_contents(); | ||
ob_end_clean(); | ||
|
||
return $content; | ||
} | ||
|
||
public static function createFromContent(string $content = ''): self | ||
{ | ||
$response = new self(); | ||
$response->setCallback(function () use ($content) { | ||
echo $content; | ||
}); | ||
$response->headers->set('Content-Type', 'text/html'); | ||
|
||
return $response; | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.