Skip to content

Commit

Permalink
Change: Use semantic configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
TPete committed Jun 16, 2015
1 parent de80a9c commit 2232bd0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
15 changes: 15 additions & 0 deletions DependencyInjection/CheckdomainTeleCashExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ class CheckdomainTeleCashExtension extends Extension
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$container->setParameter('checkdomain_tele_cash.service_url', $config['service_url']);

$container->setParameter('checkdomain_tele_cash.api.user', $config['api']['user']);
$container->setParameter('checkdomain_tele_cash.api.pass', $config['api']['pass']);

$container->setParameter('checkdomain_tele_cash.client_cert_path', $config['client_cert_path']);

$container->setParameter('checkdomain_tele_cash.client_key.path', $config['client_key']['path']);
$container->setParameter('checkdomain_tele_cash.client_key.pass_phrase', $config['client_key']['pass_phrase']);

$container->setParameter('checkdomain_tele_cash.server_cert_path', $config['server_cert_path']);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
Expand Down
20 changes: 20 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('checkdomain_tele_cash');

$rootNode
->children()
->arrayNode('api')
->children()
->scalarNode('user')->isRequired()->cannotBeEmpty()->end()
->scalarNode('pass')->isRequired()->cannotBeEmpty()->end()
->end()
->end()
->arrayNode('client_key')
->children()
->scalarNode('path')->isRequired()->cannotBeEmpty()->end()
->scalarNode('pass_phrase')->isRequired()->cannotBeEmpty()->end()
->end()
->end()
->scalarNode('client_cert_path')->isRequired()->cannotBeEmpty()->end()
->scalarNode('server_cert_path')->isRequired()->cannotBeEmpty()->end()
->scalarNode('service_url')->isRequired()->cannotBeEmpty()->end()
->end();

return $treeBuilder;
}
Expand Down
14 changes: 7 additions & 7 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ services:
checkdomain.telecash.telecash:
class: %checkdomain.telecash.class%
arguments:
- %telecash_service_url%
- %telecash_api_user%
- %telecash_api_pass%
- %telecash_client_cert_path%
- %telecash_client_key_path%
- %telecash_client_key_pass_phrase%
- %telecash_server_cert%
- %checkdomain_tele_cash.service_url%
- %checkdomain_tele_cash.api.user%
- %checkdomain_tele_cash.api.pass%
- %checkdomain_tele_cash.client_cert_path%
- %checkdomain_tele_cash.client_key.path%
- %checkdomain_tele_cash.client_key.pass_phrase%
- %checkdomain_tele_cash.server_cert_path%

0 comments on commit 2232bd0

Please sign in to comment.