Created basic functionality. May be buggy sometimes yet.

This commit is contained in:
Gergely POLONKAI
2012-10-07 01:35:20 +02:00
parent 2e8eadf32c
commit 47086cc541
5 changed files with 146 additions and 1 deletions

View File

@@ -0,0 +1,46 @@
<?php
namespace GergelyPolonkai\SmsSenderBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* Description of Configuration
*
* @author Gergely Polonkai
*/
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('gergely_polonkai_sms_sender');
$rootNode
->children()
->booleanNode('verify_ssl')
->defaultTrue()
->end()
->scalarNode('sender_url')
->isRequired()
->end()
->scalarNode('content_type')
->defaultValue('application/json')
->end()
->scalarNode('content_encoding')
->defaultValue('utf-8')
->end()
->booleanNode('verbose_curl')
->defaultFalse()
->end()
->scalarNode('username')
->isRequired()
->end()
->scalarNode('password')
->isRequired()
->end()
->end();
return $treeBuilder;
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace GergelyPolonkai\SmsSenderBundle\DependencyInjection;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\Config\FileLocator;
/**
* Description of GergelyPolonkaiSmsSenderExtension
*
* @author Gergely Polonkai
*/
class GergelyPolonkaiSmsSenderExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
$container->setParameter('verify_ssl', $config['verify_ssl']);
$container->setParameter('sender_url', $config['sender_url']);
$container->setParameter('content_type', $config['content_type']);
$container->setParameter('content_encoding', $config['content_encoding']);
$container->setParameter('verbose_curl', $config['verbose_curl']);
$container->setParameter('username', $config['username']);
$container->setParameter('password', $config['password']);
}
}