Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitf9bb4ab

Browse files
committed
feature#19452 Remove the new SecurityUserValueResolver (weaverryan)
This PR was merged into the 3.2-dev branch.Discussion----------Remove the new SecurityUserValueResolver| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no (the feature hasn't been released yet)| Deprecations? | no| Tests pass? | yes| Fixed tickets | n/a| License | MIT| Doc PR | n/aHi guys!This is a revert for#18510 (ping@iltar), which is a nice idea, but will have some big practical implications:1) You are only allowed to type-hint the argument with `UserInterface` exactly. For the 90% of Symfony project's that user a User entity for their User, this will be weird: I'll receive a `UserInterface`, that immediately call methods on it that aren't in the interface (and also, your IDE won't give you auto-completion). And as#18510 mentions, we can't allow people to type-hint their concrete `User` class, because this will conflict with SensioFWExtraBundle ParamConverter if there is a user id in the URL2) Deprecating and removing `$this->getUser()` in a controller is a step back. Where we can, let's make controllers and services act *more* like each other. You can't call `$this->getUser()` in a service, but at least if you look at this method in `Controller`, you can see that it uses `security.token_storage` - which is how you will get the User object if you need it from within services.Sorry for being late on this original issue! It looked good to me at first :).Cheers!Commits-------da7daee Removing the Controller::getUser() deprecation
2 parents870c302 +da7daee commitf9bb4ab

File tree

5 files changed

+0
-22
lines changed

5 files changed

+0
-22
lines changed

‎UPGRADE-3.2.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ FrameworkBundle
2727
* The`Resources/public/images/*` files have been removed.
2828
* The`Resources/public/css/*.css` files have been removed (they are now inlined
2929
in TwigBundle).
30-
* The`Controller::getUser()` method has been deprecated and will be removed in
31-
Symfony 4.0; typehint the security user object in the action instead.
3230

3331
Console
3432
-------

‎UPGRADE-4.0.md‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ FrameworkBundle
124124
`serializer.mapping.cache.apc` and`serializer.mapping.cache.doctrine.apc`
125125
have been removed. APCu should now be automatically used when available.
126126

127-
* The`Controller::getUser()` method has been removed in favor of the ability
128-
to typehint the security user object in the action.
129-
130127
HttpFoundation
131128
---------------
132129

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ CHANGELOG
1111
* Removed`symfony/asset` from the list of required dependencies in`composer.json`
1212
* The`Resources/public/images/*` files have been removed.
1313
* The`Resources/public/css/*.css` files have been removed (they are now inlined in TwigBundle).
14-
* The`Controller::getUser()` method has been deprecated and will be removed in
15-
Symfony 4.0; typehint the security user object in the action instead.
1614
* Added possibility to prioritize form type extensions with`'priority'` attribute on tags`form.type_extension`
1715

1816
3.1.0

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
useSymfony\Component\HttpKernel\Exception\NotFoundHttpException;
2323
useSymfony\Component\HttpKernel\HttpKernelInterface;
2424
useSymfony\Component\Security\Core\Exception\AccessDeniedException;
25-
useSymfony\Component\Security\Core\User\UserInterface;
2625
useSymfony\Component\Security\Csrf\CsrfToken;
2726
useSymfony\Component\Form\Extension\Core\Type\FormType;
2827
useSymfony\Component\Form\Form;
@@ -367,16 +366,12 @@ protected function getDoctrine()
367366
*
368367
* @return mixed
369368
*
370-
* @deprecated as of 3.2 and will be removed in 4.0. You can typehint your method argument with Symfony\Component\Security\Core\User\UserInterface instead.
371-
*
372369
* @throws \LogicException If SecurityBundle is not available
373370
*
374371
* @see TokenInterface::getUser()
375372
*/
376373
protectedfunctiongetUser()
377374
{
378-
@trigger_error(sprintf('%s() is deprecated as of 3.2 and will be removed in 4.0. You can typehint your method argument with %s instead.',__METHOD__, UserInterface::class),E_USER_DEPRECATED);
379-
380375
if (!$this->container->has('security.token_storage')) {
381376
thrownew \LogicException('The SecurityBundle is not registered in your application.');
382377
}

‎src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ public function testForward()
5656
$this->assertEquals('xml--fr',$response->getContent());
5757
}
5858

59-
/**
60-
* @group legacy
61-
*/
6259
publicfunctiontestGetUser()
6360
{
6461
$user =newUser('user','pass');
@@ -70,9 +67,6 @@ public function testGetUser()
7067
$this->assertSame($controller->getUser(),$user);
7168
}
7269

73-
/**
74-
* @group legacy
75-
*/
7670
publicfunctiontestGetUserAnonymousUserConvertedToNull()
7771
{
7872
$token =newAnonymousToken('default','anon.');
@@ -83,9 +77,6 @@ public function testGetUserAnonymousUserConvertedToNull()
8377
$this->assertNull($controller->getUser());
8478
}
8579

86-
/**
87-
* @group legacy
88-
*/
8980
publicfunctiontestGetUserWithEmptyTokenStorage()
9081
{
9182
$controller =newTestController();
@@ -95,7 +86,6 @@ public function testGetUserWithEmptyTokenStorage()
9586
}
9687

9788
/**
98-
* @group legacy
9989
* @expectedException \LogicException
10090
* @expectedExceptionMessage The SecurityBundle is not registered in your application.
10191
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp