14
14
use Symfony \Bundle \SecurityBundle \DependencyInjection \Security \Factory \SecurityFactoryInterface ;
15
15
use Symfony \Component \Config \Definition \Builder \NodeDefinition ;
16
16
use Symfony \Component \DependencyInjection \ContainerBuilder ;
17
+ use Symfony \Component \DependencyInjection \ChildDefinition ;
17
18
use Symfony \Component \DependencyInjection \DefinitionDecorator ;
18
19
use Symfony \Component \DependencyInjection \Reference ;
19
20
@@ -30,13 +31,24 @@ class OAuthFactory implements SecurityFactoryInterface
30
31
public function create (ContainerBuilder $ container , $ id , $ config , $ userProvider , $ defaultEntryPoint )
31
32
{
32
33
$ providerId = 'security.authentication.provider.fos_oauth_server. ' .$ id ;
34
+ if (class_exists (ChildDefinition::class)) {
35
+ $ definition = new ChildDefinition ('fos_oauth_server.security.authentication.provider ' );
36
+ } else {
37
+ $ definition = new DefinitionDecorator ('fos_oauth_server.security.authentication.provider ' );
38
+ }
33
39
$ container
34
- ->setDefinition ($ providerId , new DefinitionDecorator ( ' fos_oauth_server.security.authentication.provider ' ) )
40
+ ->setDefinition ($ providerId , $ definition )
35
41
->replaceArgument (0 , new Reference ($ userProvider ))
36
- ;
42
+ ;
37
43
38
44
$ listenerId = 'security.authentication.listener.fos_oauth_server. ' .$ id ;
39
- $ container ->setDefinition ($ listenerId , new DefinitionDecorator ('fos_oauth_server.security.authentication.listener ' ));
45
+
46
+ if (class_exists (ChildDefinition::class)) {
47
+ $ definition = new ChildDefinition ('fos_oauth_server.security.authentication.listener ' );
48
+ } else {
49
+ $ definition = new DefinitionDecorator ('fos_oauth_server.security.authentication.listener ' );
50
+ }
51
+ $ container ->setDefinition ($ listenerId , $ definition );
40
52
41
53
return array ($ providerId , $ listenerId , 'fos_oauth_server.security.entry_point ' );
42
54
}
0 commit comments