Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a1d6134

Browse files
committed
minor #46602 [SecurityBundle] Add service alias for legacy Security helper (HypeMC)
This PR was merged into the 6.2 branch. Discussion ---------- [SecurityBundle] Add service alias for legacy Security helper | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | yes | New feature? | no | Deprecations? | yes | Tickets | - | License | MIT | Doc PR | - The service alias for `Symfony\Component\Security\Core\Security` was removed in #46094 which causes existing code to break when upgrading to 6.2, eg: ```php use Symfony\Component\Security\Core\Security; class HomeController extends AbstractController { public function __construct(private Security $security) { } } ``` results in: ![image](https://user-images.githubusercontent.com/2445045/172196153-dbcacf0e-0632-40ad-87a2-bbe7774cc698.png) Commits ------- 0b81a75 [SecurityBundle] Add service alias for legacy Security helper
2 parents 082d88f + 0b81a75 commit a1d6134

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

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

77
* Add the `Security` helper class
8+
* Deprecate the `Symfony\Component\Security\Core\Security` service alias, use `Symfony\Bundle\SecurityBundle\Security\Security` instead
89

910
6.1
1011
---

src/Symfony/Bundle/SecurityBundle/Resources/config/security.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use Symfony\Component\Security\Core\Authorization\Voter\RoleVoter;
3535
use Symfony\Component\Security\Core\Role\RoleHierarchy;
3636
use Symfony\Component\Security\Core\Role\RoleHierarchyInterface;
37+
use Symfony\Component\Security\Core\Security as LegacySecurity;
3738
use Symfony\Component\Security\Core\User\ChainUserProvider;
3839
use Symfony\Component\Security\Core\User\InMemoryUserChecker;
3940
use Symfony\Component\Security\Core\User\InMemoryUserProvider;
@@ -81,6 +82,8 @@
8182
'security.authorization_checker' => service('security.authorization_checker'),
8283
])])
8384
->alias(Security::class, 'security.helper')
85+
->alias(LegacySecurity::class, 'security.helper')
86+
->deprecate('symfony/security-bundle', '6.2', 'The "%alias_id%" service alias is deprecated, use "'.Security::class.'" instead.')
8487

8588
->set('security.user_value_resolver', UserValueResolver::class)
8689
->args([

0 commit comments

Comments
 (0)