nexmo-bundle/DependencyInjection/Configuration.php

51 lines
1.4 KiB
PHP
Raw Normal View History

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()
->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()
->booleanNode('disable_delivery')
->defaultFalse()
->end()
2013-12-09 19:29:26 +00:00
->end()
;
return $treeBuilder;
}
}