Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dae0291

Browse filesBrowse files
feature #41530 [FrameworkBundle] Deprecate the public profiler service to private (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- [FrameworkBundle] Deprecate the public `profiler` service to private | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | yes | Tickets | - | License | MIT | Doc PR | - One less public service \o/ Commits ------- 06b13c3 [FrameworkBundle] Deprecate the public `profiler` service to private
2 parents 1509797 + 06b13c3 commit dae0291
Copy full SHA for dae0291

File tree

5 files changed

+17
-8
lines changed
Filter options

5 files changed

+17
-8
lines changed

‎UPGRADE-5.4.md

Copy file name to clipboardExpand all lines: UPGRADE-5.4.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ FrameworkBundle
55
---------------
66

77
* Deprecate the `AdapterInterface` autowiring alias, use `CacheItemPoolInterface` instead
8+
* Deprecate the public `profiler` service to private
89

910
HttpKernel
1011
----------

‎UPGRADE-6.0.md

Copy file name to clipboardExpand all lines: UPGRADE-6.0.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ FrameworkBundle
8282
* `MicroKernelTrait::configureRoutes()` is now always called with a `RoutingConfigurator`
8383
* The "framework.router.utf8" configuration option defaults to `true`
8484
* Removed `session.attribute_bag` service and `session.flash_bag` service.
85-
* The `form.factory`, `form.type.file`, `translator`, `security.csrf.token_manager`, `serializer`,
85+
* The `form.factory`, `form.type.file`, `profiler`, `translator`, `security.csrf.token_manager`, `serializer`,
8686
`cache_clearer`, `filesystem` and `validator` services are now private.
8787
* Removed the `lock.RESOURCE_NAME` and `lock.RESOURCE_NAME.store` services and the `lock`, `LockInterface`, `lock.store` and `PersistingStoreInterface` aliases, use `lock.RESOURCE_NAME.factory`, `lock.factory` or `LockFactory` instead.
8888
* Remove the `KernelTestCase::$container` property, use `KernelTestCase::getContainer()` instead

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
* Add autowiring alias for `HttpCache\StoreInterface`
88
* Deprecate the `AdapterInterface` autowiring alias, use `CacheItemPoolInterface` instead
9+
* Deprecate the public `profiler` service to private
910

1011
5.3
1112
---

‎src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php
+13-7Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ public function __construct(KernelInterface $kernel, array $server = [], History
4949
*/
5050
public function getContainer()
5151
{
52-
return $this->kernel->getContainer();
52+
$container = $this->kernel->getContainer();
53+
54+
return $container->has('test.service_container') ? $container->get('test.service_container') : $container;
5355
}
5456

5557
/**
@@ -69,11 +71,11 @@ public function getKernel()
6971
*/
7072
public function getProfile()
7173
{
72-
if (null === $this->response || !$this->kernel->getContainer()->has('profiler')) {
74+
if (null === $this->response || !$this->getContainer()->has('profiler')) {
7375
return false;
7476
}
7577

76-
return $this->kernel->getContainer()->get('profiler')->loadProfileFromResponse($this->response);
78+
return $this->getContainer()->get('profiler')->loadProfileFromResponse($this->response);
7779
}
7880

7981
/**
@@ -83,7 +85,7 @@ public function getProfile()
8385
*/
8486
public function enableProfiler()
8587
{
86-
if ($this->kernel->getContainer()->has('profiler')) {
88+
if ($this->getContainer()->has('profiler')) {
8789
$this->profiler = true;
8890
}
8991
}
@@ -123,7 +125,7 @@ public function loginUser($user, string $firewallContext = 'main'): self
123125
$token = new TestBrowserToken($user->getRoles(), $user, $firewallContext);
124126
$token->setAuthenticated(true);
125127

126-
$container = $this->kernel->getContainer()->get('test.service_container');
128+
$container = $this->getContainer();
127129
$container->get('security.untracked_token_storage')->setToken($token);
128130

129131
if (!$container->has('session') && !$container->has('session_factory')) {
@@ -161,7 +163,7 @@ protected function doRequest($request)
161163
$this->profiler = false;
162164

163165
$this->kernel->boot();
164-
$this->kernel->getContainer()->get('profiler')->enable();
166+
$this->getContainer()->get('profiler')->enable();
165167
}
166168

167169
return parent::doRequest($request);
@@ -220,7 +222,11 @@ protected function getScript($request)
220222

221223
$profilerCode = '';
222224
if ($this->profiler) {
223-
$profilerCode = '$kernel->getContainer()->get(\'profiler\')->enable();';
225+
$profilerCode = <<<'EOF'
226+
$container = $kernel->getContainer();
227+
$container = $container->has('test.service_container') ? $container->get('test.service_container') : $container;
228+
$container->get('profiler')->enable();
229+
EOF;
224230
}
225231

226232
$code = <<<EOF

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
->public()
2222
->args([service('profiler.storage'), service('logger')->nullOnInvalid()])
2323
->tag('monolog.logger', ['channel' => 'profiler'])
24+
->tag('container.private', ['package' => 'symfony/framework-bundle', 'version' => '5.4'])
2425

2526
->set('profiler.storage', FileProfilerStorage::class)
2627
->args([param('profiler.storage.dsn')])

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.