@@ -41,6 +41,7 @@ class FOSUserExtension extends Extension
4141 );
4242
4343 private $ mailerNeeded = false ;
44+ private $ sessionNeeded = false ;
4445
4546 /**
4647 * {@inheritdoc}
@@ -78,6 +79,7 @@ public function load(array $configs, ContainerBuilder $container)
7879 }
7980
8081 if ($ config ['use_flash_notifications ' ]) {
82+ $ this ->sessionNeeded = true ;
8183 $ loader ->load ('flash_notifications.xml ' );
8284 }
8385
@@ -130,6 +132,11 @@ public function load(array $configs, ContainerBuilder $container)
130132 if ($ this ->mailerNeeded ) {
131133 $ container ->setAlias ('fos_user.mailer ' , $ config ['service ' ]['mailer ' ]);
132134 }
135+
136+ if ($ this ->sessionNeeded ) {
137+ // Use a private alias rather than a parameter, to avoid leaking it at runtime (the private alias will be removed)
138+ $ container ->setAlias ('fos_user.session ' , new Alias ('session ' , false ));
139+ }
133140 }
134141
135142 /**
@@ -203,6 +210,7 @@ private function loadProfile(array $config, ContainerBuilder $container, XmlFile
203210 private function loadRegistration (array $ config , ContainerBuilder $ container , XmlFileLoader $ loader , array $ fromEmail )
204211 {
205212 $ loader ->load ('registration.xml ' );
213+ $ this ->sessionNeeded = true ;
206214
207215 if ($ config ['confirmation ' ]['enabled ' ]) {
208216 $ this ->mailerNeeded = true ;
0 commit comments