2013-12-09 19:29:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Jhg\NexmoBundle\DependencyInjection;
|
|
|
|
|
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the class that validates and merges configuration from your app/config files
|
|
|
|
*
|
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
|
|
|
|
*/
|
|
|
|
class Configuration implements ConfigurationInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function getConfigTreeBuilder()
|
|
|
|
{
|
|
|
|
$treeBuilder = new TreeBuilder();
|
|
|
|
$rootNode = $treeBuilder->root('jhg_nexmo');
|
|
|
|
|
|
|
|
$rootNode
|
|
|
|
->children()
|
2014-03-30 22:20:02 +00:00
|
|
|
->scalarNode('api_key')
|
|
|
|
->isRequired()
|
|
|
|
->end()
|
|
|
|
|
|
|
|
->scalarNode('api_secret')
|
|
|
|
->isRequired()
|
|
|
|
->end()
|
|
|
|
|
2014-04-08 19:45:45 +00:00
|
|
|
->enumNode('api_method')
|
|
|
|
->defaultValue('GET')
|
|
|
|
->values(array('GET','POST'))
|
|
|
|
->end()
|
|
|
|
|
2014-03-30 22:20:02 +00:00
|
|
|
->scalarNode('from_name')
|
|
|
|
->validate()
|
|
|
|
->ifTrue(function ($s) {
|
|
|
|
return (strlen($s)>11 || strlen($s)<2) && preg_match('/^[0-9a-z]{11}$/i', $s) !== 1;
|
|
|
|
})
|
|
|
|
->thenInvalid('Invalid from_name, only alphanumeric characters are allowed')
|
|
|
|
->end()
|
|
|
|
->end()
|
|
|
|
|
2014-04-08 19:45:45 +00:00
|
|
|
->scalarNode('delivery_phone')
|
|
|
|
->defaultNull()
|
|
|
|
->end()
|
|
|
|
|
2014-03-30 22:20:02 +00:00
|
|
|
->booleanNode('disable_delivery')
|
|
|
|
->defaultFalse()
|
|
|
|
->end()
|
2013-12-09 19:29:26 +00:00
|
|
|
->end()
|
|
|
|
;
|
2014-04-08 19:45:45 +00:00
|
|
|
|
2013-12-09 19:29:26 +00:00
|
|
|
return $treeBuilder;
|
|
|
|
}
|
|
|
|
}
|