Skip to content

Commit f27384d

Browse files
Josef Panákdkarlovi
authored andcommitted
add compatibility with Symfony 4.0 and Symfony 2.8
1 parent 8bb0b8f commit f27384d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

DependencyInjection/Security/Factory/OAuthFactory.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
1515
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\DependencyInjection\ChildDefinition;
1718
use Symfony\Component\DependencyInjection\DefinitionDecorator;
1819
use Symfony\Component\DependencyInjection\Reference;
1920

@@ -30,13 +31,24 @@ class OAuthFactory implements SecurityFactoryInterface
3031
public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint)
3132
{
3233
$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+
}
3339
$container
34-
->setDefinition($providerId, new DefinitionDecorator('fos_oauth_server.security.authentication.provider'))
40+
->setDefinition($providerId, $definition)
3541
->replaceArgument(0, new Reference($userProvider))
36-
;
42+
;
3743

3844
$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);
4052

4153
return array($providerId, $listenerId, 'fos_oauth_server.security.entry_point');
4254
}

0 commit comments

Comments
 (0)