Skip to content

Navigation Menu

Sign in
Appearance settings

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 09dcbfc

Browse filesBrowse files
committed
feature #36273 [FrameworkBundle] Deprecate flashbag and attributebag services (William Arslett)
This PR was squashed before being merged into the 5.1-dev branch. Discussion ---------- [FrameworkBundle] Deprecate flashbag and attributebag services | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | Deprecations? | yes | Tickets | Related to [#10557](#10557) | Related to PR | #36063 | License | MIT FlashBag and AttributeBag are data objects and so should not be available via the service container. The preferred method for accessing these objects is via `$session->getFlashBag()` or `$session->getAttributeBag()` Commits ------- f9b52fe [FrameworkBundle] Deprecate flashbag and attributebag services
2 parents 9381dd6 + f9b52fe commit 09dcbfc
Copy full SHA for 09dcbfc

File tree

5 files changed

+12
-0
lines changed
Filter options

5 files changed

+12
-0
lines changed

‎UPGRADE-5.1.md

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

3838
* Deprecated passing a `RouteCollectionBuilder` to `MicroKernelTrait::configureRoutes()`, type-hint `RoutingConfigurator` instead
3939
* Deprecated *not* setting the "framework.router.utf8" configuration option as it will default to `true` in Symfony 6.0
40+
* Deprecated `session.attribute_bag` service and `session.flash_bag` service.
4041

4142
HttpFoundation
4243
--------------

‎UPGRADE-6.0.md

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

3636
* `MicroKernelTrait::configureRoutes()` is now always called with a `RoutingConfigurator`
3737
* The "framework.router.utf8" configuration option defaults to `true`
38+
* Removed `session.attribute_bag` service and `session.flash_bag` service.
3839

3940
HttpFoundation
4041
--------------

‎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
@@ -17,6 +17,7 @@ CHANGELOG
1717
* Added `debug:container --deprecations` option to see compile-time deprecations.
1818
* Made `BrowserKitAssertionsTrait` report the original error message in case of a failure
1919
* Added ability for `config:dump-reference` and `debug:config` to dump and debug kernel container extension configuration.
20+
* Deprecated `session.attribute_bag` service and `session.flash_bag` service.
2021

2122
5.0.0
2223
-----

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@
4343

4444
<service id="session.flash_bag" class="Symfony\Component\HttpFoundation\Session\Flash\FlashBag">
4545
<factory service="session" method="getFlashBag" />
46+
<deprecated package="symfony/framework-bundle" version="5.1">The "%service_id%" service is deprecated, use "$session->getFlashBag()" instead.</deprecated>
4647
</service>
4748
<service id="Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface" alias="session.flash_bag" />
4849

4950
<service id="session.attribute_bag" class="Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag">
5051
<factory service="session" method="getAttributeBag" />
52+
<deprecated package="symfony/framework-bundle" version="5.1">The "%service_id%" service is deprecated, use "$session->getAttributeBag()" instead.</deprecated>
5153
</service>
5254

5355
<service id="session.storage.mock_file" class="Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage">

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
1313

14+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
15+
1416
class SessionTest extends AbstractWebTestCase
1517
{
18+
use ExpectDeprecationTrait;
19+
1620
/**
1721
* Tests session attributes persist.
1822
*
@@ -72,10 +76,13 @@ public function testFlash($config, $insulate)
7276
/**
7377
* Tests flash messages work when flashbag service is injected to the constructor.
7478
*
79+
* @group legacy
7580
* @dataProvider getConfigs
7681
*/
7782
public function testFlashOnInjectedFlashbag($config, $insulate)
7883
{
84+
$this->expectDeprecation('Since symfony/framework-bundle 5.1: The "session.flash_bag" service is deprecated, use "$session->getFlashBag()" instead.');
85+
7986
$client = $this->createClient(['test_case' => 'Session', 'root_config' => $config]);
8087
if ($insulate) {
8188
$client->insulate();

0 commit comments

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