Skip to content

Commit

Permalink
Merge pull request #6 from thomaskonrad/websms
Browse files Browse the repository at this point in the history
Add websms provider
  • Loading branch information
K-Phoen committed Oct 20, 2014
2 parents 03084a8 + 8ceb353 commit cc619f1
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
46 changes: 46 additions & 0 deletions DependencyInjection/Factory/WebsmsProviderFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace KPhoen\SmsSenderBundle\DependencyInjection\Factory;

use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* websms provider factory
*
* @author Thomas Konrad <[email protected]>
*/
class WebsmsProviderFactory implements ProviderFactoryInterface
{
/**
* {@inheritDoc}
*/
public function create(ContainerBuilder $container, $id, array $config)
{
$container->getDefinition($id)
->replaceArgument(1, $config['access_token'])
->replaceArgument(2, $config['international_prefix'])
;
}

/**
* {@inheritDoc}
*/
public function getKey()
{
return 'websms';
}

/**
* {@inheritDoc}
*/
public function addConfiguration(NodeDefinition $node)
{
$node
->children()
->scalarNode('access_token')->isRequired()->end()
->scalarNode('international_prefix')->defaultValue('+43')->end()
->end()
;
}
}
4 changes: 4 additions & 0 deletions Resources/config/provider_factories.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<tag name="sms.provider.factory" />
</service>

<service id="sms.provider.factory.websms" class="KPhoen\SmsSenderBundle\DependencyInjection\Factory\WebsmsProviderFactory">
<tag name="sms.provider.factory" />
</service>

<service id="sms.provider.factory.dummy" class="KPhoen\SmsSenderBundle\DependencyInjection\Factory\DummyProviderFactory">
<tag name="sms.provider.factory" />
</service>
Expand Down
8 changes: 8 additions & 0 deletions Resources/config/providers.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@
<argument></argument>
</service>

<service id="sms.provider.websms" class="SmsSender\Provider\WebsmsProvider" public="false">
<argument type="service" id="sms.http_adapter" />
<!-- Access token -->
<argument></argument>
<!-- International prefix -->
<argument></argument>
</service>

<service id="sms.provider.dummy" class="SmsSender\Provider\DummyProvider" public="false">
</service>
</services>
Expand Down
4 changes: 4 additions & 0 deletions Resources/doc/index.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,8 @@ k_phoen_sms_sender:
swisscom:
client_id: lala
international_prefix: '+41'
websms:
access_token: lala
international_prefix: '+43'
```

0 comments on commit cc619f1

Please sign in to comment.