Skip to content

Commit

Permalink
Removing 2.3 compat on DI - it was too much trouble
Browse files Browse the repository at this point in the history
But, I did need 2.3 on router (which is fine) - before it was using something even lower,
which caused incompatibilities. Anyways, this configuration finally works with low deps set
on Composer.
  • Loading branch information
weaverryan committed Jan 17, 2016
1 parent 06cc3a9 commit d4a3dce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 27 deletions.
15 changes: 5 additions & 10 deletions DependencyInjection/KnpUOAuth2ClientExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,11 @@ private function configureProvider(ContainerBuilder $container, $providerType, $
$providerClass
);

if (method_exists($definition, 'setFactory')) {
$definition->setFactory(array(
new Reference('knpu.oauth.provider_factory'),
'createProvider'
));
} else {
// for 2.3-2.5 compatibility
$definition->setFactoryService('knpu.oauth.provider_factory');
$definition->setFactoryMethod('createProvider');
}
$definition->setFactory(array(
new Reference('knpu.oauth.provider_factory'),
'createProvider'
));

$definition->setArguments(array(
$providerClass,
$options,
Expand Down
23 changes: 6 additions & 17 deletions Tests/DependencyInjection/KnpUOAuth2ClientExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,12 @@ public function testFacebookProviderMakesService()

$definition = $this->configuration->getDefinition('knpu.oauth2.facebook_client');

if (method_exists($definition, 'getFactory')) {
$factory = $definition->getFactory();
// make sure the factory is correct
$this->assertEquals(
array(new Reference('knpu.oauth.provider_factory'), 'createProvider'),
$factory
);
} else {
// 2.3-2.5 compat
$factoryService = $definition->getFactoryService();
// make sure the factory is correct
$this->assertEquals(
'knpu.oauth.provider_factory',
$factoryService
);
$this->assertEquals('createProvider', $definition->getFactoryMethod());
}
$factory = $definition->getFactory();
// make sure the factory is correct
$this->assertEquals(
array(new Reference('knpu.oauth.provider_factory'), 'createProvider'),
$factory
);

$this->assertEquals(
array(
Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
],
"require": {
"symfony/framework-bundle": "~2.3|~3.0",
"symfony/dependency-injection": "~2.7|~3.0",
"symfony/routing": "~2.3|~3.0",
"league/oauth2-client": "^1.0"
},
"autoload": {
Expand Down

0 comments on commit d4a3dce

Please sign in to comment.