Skip to content

Commit ade06ea

Browse files
Bilgefabpot
authored andcommitted
[HttpKernel] Add Profiler::isEnabled() method
1 parent 6b14a4c commit ade06ea

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
* Add `BackedEnumValueResolver` to resolve backed enum cases from request attributes in controller arguments
88
* Deprecate StreamedResponseListener, it's not needed anymore
9+
* Add `Profiler::isEnabled()` so collaborating collector services may elect to omit themselves.
910

1011
6.0
1112
---

Profiler/Profiler.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public function enable()
6060
$this->enabled = true;
6161
}
6262

63+
public function isEnabled(): bool
64+
{
65+
return $this->enabled;
66+
}
67+
6368
/**
6469
* Loads the Profile for the given Response.
6570
*/

Tests/Profiler/ProfilerTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,28 @@ public function testFindWorksWithStatusCode()
8383
$this->assertCount(0, $profiler->find(null, null, null, null, null, null, '204'));
8484
}
8585

86+
public function testIsInitiallyEnabled()
87+
{
88+
self::assertTrue((new Profiler($this->storage))->isEnabled());
89+
}
90+
91+
public function testDisable()
92+
{
93+
$profiler = new Profiler($this->storage);
94+
$profiler->disable();
95+
96+
self::assertFalse($profiler->isEnabled());
97+
}
98+
99+
public function testEnable()
100+
{
101+
$profiler = new Profiler($this->storage);
102+
$profiler->disable();
103+
$profiler->enable();
104+
105+
self::assertTrue($profiler->isEnabled());
106+
}
107+
86108
protected function setUp(): void
87109
{
88110
$this->tmp = tempnam(sys_get_temp_dir(), 'sf_profiler');

0 commit comments

Comments
 (0)