File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed
Bundle/TestBundle/Controller Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Bundle \FrameworkBundle \Tests \Functional \Bundle \TestBundle \Controller ;
13
13
14
- use Symfony \Component \DependencyInjection \ContainerAwareInterface ;
15
- use Symfony \Component \DependencyInjection \ContainerAwareTrait ;
14
+ use Psr \Container \ContainerInterface ;
16
15
use Symfony \Component \HttpFoundation \Response ;
16
+ use Symfony \Component \Security \Core \Authentication \Token \Storage \TokenStorageInterface ;
17
+ use Symfony \Contracts \Service \ServiceSubscriberInterface ;
17
18
18
- class SecurityController implements ContainerAwareInterface
19
+ class SecurityController implements ServiceSubscriberInterface
19
20
{
20
- use ContainerAwareTrait;
21
+ private $ container ;
22
+
23
+ public function __construct (ContainerInterface $ container )
24
+ {
25
+ $ this ->container = $ container ;
26
+ }
21
27
22
28
public function profileAction ()
23
29
{
24
30
return new Response ('Welcome ' .$ this ->container ->get ('security.token_storage ' )->getToken ()->getUserIdentifier ().'! ' );
25
31
}
32
+
33
+ /**
34
+ * {@inheritdoc}
35
+ */
36
+ public static function getSubscribedServices (): array
37
+ {
38
+ return [
39
+ 'security.token_storage ' => TokenStorageInterface::class,
40
+ ];
41
+ }
26
42
}
Original file line number Diff line number Diff line change 1
1
imports :
2
2
- { resource: ./../config/default.yml }
3
3
4
+ services :
5
+ Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SecurityController :
6
+ public : true
7
+ tags :
8
+ - container.service_subscriber
9
+
4
10
security :
5
11
providers :
6
12
main :
You can’t perform that action at this time.
0 commit comments