Skip to content
This repository has been archived by the owner on Nov 20, 2019. It is now read-only.

Commit

Permalink
Allow ruudk_mollie.buzz_client variable to be a service id
Browse files Browse the repository at this point in the history
  • Loading branch information
ruudk committed Dec 17, 2012
1 parent 2a5d4e5 commit 8eef0b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 0 additions & 4 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public function getConfigTreeBuilder()
->end()
->scalarNode('buzz_client')
->defaultValue('file_get_contents')
->validate()
->ifNotInArray(array('file_get_contents', 'curl'))
->thenInvalid('Buzz client %s is not supported')
->end()
->end()
->end()
;
Expand Down
7 changes: 6 additions & 1 deletion DependencyInjection/RuudkMollieExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Definition;

class RuudkMollieExtension extends Extension
{
Expand All @@ -39,7 +40,11 @@ public function load(array $configs, ContainerBuilder $container)
}

if (isset($config['buzz_client'])) {
$container->setParameter('ruudk_mollie.buzz_client.class', $config['buzz_client'] == 'curl' ? 'Buzz\Client\Curl' : 'Buzz\Client\FileGetContents');
if (in_array($config['buzz_client'], array('curl', 'file_get_contents'))) {
$container->setDefinition('ruudk_mollie.buzz_client', new Definition($config['buzz_client'] == 'curl' ? 'Buzz\Client\Curl' : 'Buzz\Client\FileGetContents'));
} else {
$container->setAlias('ruudk_mollie.buzz_client', $config['buzz_client']);
}
}
}
}
3 changes: 0 additions & 3 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<parameter key="ruudk_mollie.partner_id"/>
<parameter key="ruudk_mollie.profile_key"/>
<parameter key="ruudk_mollie.testmode"/>
<parameter key="ruudk_mollie.buzz_client.class">Buzz\Client\FileGetContents</parameter>
<parameter key="ruudk_mollie.ideal_gateway.class">AMNL\Mollie\IDeal\IDealGateway</parameter>
<parameter key="ruudk_mollie.ivr_gateway.class">AMNL\Mollie\IVR\MicropaymentGateway</parameter>
<parameter key="ruudk_mollie.minitix_gateway.class">AMNL\Mollie\MiniTix\MiniTixGateway</parameter>
Expand Down Expand Up @@ -36,8 +35,6 @@
<argument type="service" id="ruudk_mollie.buzz_client" />
</service>

<service id="ruudk_mollie.buzz_client" class="%ruudk_mollie.buzz_client.class%" />

<service id="mollie.ideal" alias="ruudk_mollie.ideal_gateway"/>
<service id="mollie.ivr" alias="ruudk_mollie.ivr_gateway"/>
<service id="mollie.minitix" alias="ruudk_mollie.minitix_gateway"/>
Expand Down

0 comments on commit 8eef0b6

Please sign in to comment.