|
12 | 12 | namespace FOS\OAuthServerBundle\DependencyInjection;
|
13 | 13 |
|
14 | 14 | use Symfony\Component\Config\Definition\Processor;
|
| 15 | +use Symfony\Component\DependencyInjection\Reference; |
15 | 16 | use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
16 | 17 | use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
17 | 18 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
@@ -74,9 +75,31 @@ public function load(array $configs, ContainerBuilder $container)
|
74 | 75 | }
|
75 | 76 | }
|
76 | 77 |
|
| 78 | + // Entity manager factory definition |
| 79 | + // TODO: Go back to xml configuration when bumping the requirement to Symfony >=2.6 |
| 80 | + if ('orm' === $config['db_driver']) { |
| 81 | + $ormEntityManagerDefinition = $container->getDefinition('fos_oauth_server.entity_manager'); |
| 82 | + if (method_exists($ormEntityManagerDefinition, 'setFactory')) { |
| 83 | + $ormEntityManagerDefinition->setFactory(array(new Reference('doctrine'), 'getManager')); |
| 84 | + } else { |
| 85 | + $ormEntityManagerDefinition->setFactoryService('doctrine'); |
| 86 | + $ormEntityManagerDefinition->setFactoryMethod('getManager'); |
| 87 | + } |
| 88 | + } |
| 89 | + |
77 | 90 | if (!empty($config['authorize'])) {
|
78 | 91 | $this->loadAuthorize($config['authorize'], $container, $loader);
|
79 | 92 | }
|
| 93 | + |
| 94 | + // Authorize form factory definition |
| 95 | + // TODO: Go back to xml configuration when bumping the requirement to Symfony >=2.6 |
| 96 | + $authorizeFormDefinition = $container->getDefinition('fos_oauth_server.authorize.form'); |
| 97 | + if (method_exists($authorizeFormDefinition, 'setFactory')) { |
| 98 | + $authorizeFormDefinition->setFactory(array(new Reference('form.factory'), 'createNamed')); |
| 99 | + } else { |
| 100 | + $authorizeFormDefinition->setFactoryService('form.factory'); |
| 101 | + $authorizeFormDefinition->setFactoryMethod('createNamed'); |
| 102 | + } |
80 | 103 | }
|
81 | 104 |
|
82 | 105 | /**
|
|
0 commit comments