Skip to content

Commit

Permalink
Bundle customizations
Browse files Browse the repository at this point in the history
  • Loading branch information
sescandell committed Oct 20, 2014
1 parent 8286acf commit 540315c
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 167 deletions.
260 changes: 123 additions & 137 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,22 @@
* Windows Azure Configuration
*
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Stéphane Escandell <stephane.escandell@gmail.com>
*/
class Configuration implements ConfigurationInterface
{
/**
* @var string
*/
protected $alias;

/**
* @param string $alias Configuration root alias
*/
public function __construct($alias)
{
$this->alias = $alias;
}

/**
* Generates the configuration tree builder.
Expand All @@ -33,144 +46,117 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('windows_azure');

$rootNode->children()
->arrayNode('services')
->children()
->arrayNode('blob')
->useAttributeAsKey('name')
->prototype('scalar')
->end()
->end()
->arrayNode('table')
->useAttributeAsKey('name')
->prototype('scalar')
->end()
->end()
->arrayNode('queue')
->useAttributeAsKey('name')
->prototype('scalar')
->end()
->end()
->arrayNode('service_bus')
->useAttributeAsKey('name')
->prototype('scalar')
->end()
->end()
->arrayNode('management')
->useAttributeAsKey('name')
->prototype('scalar')
->end()
->end()
->end()
->end()
->arrayNode('deployment')
->addDefaultsIfNotSet()
->children()
->arrayNode('roleFiles')
->children()
->scalarNode('ignoreVCS')
->defaultValue(true)
->end()
->variableNode('include')
->defaultValue(array())
->end()
->variableNode('exclude')
->defaultValue(array())
->end()
->variableNode('ignorePatterns')
->defaultValue(array())
->end()
->end()
->end()
->end()
->end()
->arrayNode('streams')
->useAttributeAsKey('name')
->prototype('scalar')
->end()
->end()
->arrayNode('key_value_store')
->addDefaultsIfNotSet()
->children()
->scalarNode('connection_name')
->defaultValue('')
->end()
->end()
->end()
->arrayNode('session')
->children()
->scalarNode('type')
->validate()
->ifNotInArray(array(
'pdo'
))
->thenInvalid('Only pdo allowed here.')
->end()
->end()
->arrayNode('database')
->children()
->scalarNode('host')
->isRequired()
->end()
->scalarNode('username')
->isRequired()
->end()
->scalarNode('password')
->isRequired()
->end()
->scalarNode('database')
->isRequired()
->end()
->scalarNode('table')
->defaultValue('azure_sessions')
->end()
->end()
->end()
->end()
->end()
->arrayNode('assets')
->addDefaultsIfNotSet()
->children()
->scalarNode('type')
->defaultValue('local')
->validate()
->ifNotInArray(array(
'local',
'blob',
'service'
))
->thenInvalid('Assets can either deployed on local "webrole" or in "blob" storage.')
->end()
->end()
->scalarNode('id')
->end()
->scalarNode('connection_name')
->end()
->end()
->end()
->arrayNode('federations')
->useAttributeAsKey('name')
->prototype('array')
$rootNode = $treeBuilder->root($this->alias);

$rootNode
->children()
->scalarNode('federationName')
->isRequired()
->end()
->scalarNode('distributionKey')
->isRequired()
->end()
->scalarNode('distributionType')
->isRequired()
->end()
->scalarNode('filteringEnabled')
->defaultValue(false)
->end()
->end()
->end()
->end()
->end();

->arrayNode('services')
->children()
->arrayNode('blob')
->useAttributeAsKey('name')
->prototype('scalar')->end()
->end()
->arrayNode('table')
->useAttributeAsKey('name')
->prototype('scalar')->end()
->end()
->arrayNode('queue')
->useAttributeAsKey('name')
->prototype('scalar')->end()
->end()
->arrayNode('service_bus')
->useAttributeAsKey('name')
->prototype('scalar')->end()
->end()
->arrayNode('management')
->useAttributeAsKey('name')
->prototype('scalar')->end()
->end()
->end()
->end()
->arrayNode('deployment')
->addDefaultsIfNotSet()
->children()
->arrayNode('roleFiles')
->children()
->scalarNode('ignoreVCS')
->defaultValue(true)
->end()
->variableNode('include')
->defaultValue(array())
->end()
->variableNode('exclude')
->defaultValue(array())
->end()
->variableNode('ignorePatterns')
->defaultValue(array())
->end()
->end()
->end()
->end()
->end()
->arrayNode('streams')
->useAttributeAsKey('name')
->prototype('scalar')->end()
->end()
->arrayNode('key_value_store')
->addDefaultsIfNotSet()
->children()
->scalarNode('connection_name')
->defaultValue('')
->end()
->end()
->end()
->arrayNode('session')
->children()
->scalarNode('type')
->validate()
->ifNotInArray(array('pdo'))
->thenInvalid('Only pdo allowed here.')
->end()
->end()
->arrayNode('database')
->children()
->scalarNode('host')->isRequired()->end()
->scalarNode('username')->isRequired()->end()
->scalarNode('password')->isRequired()->end()
->scalarNode('database')->isRequired()->end()
->scalarNode('table')->defaultValue('azure_sessions')->end()
->end()
->end()
->end()
->end()
->arrayNode('assets')
->addDefaultsIfNotSet()
->children()
->scalarNode('type')
->defaultValue('local')
->validate()
->ifNotInArray(array(
'local',
'blob',
'service'
))
->thenInvalid('Assets can either deployed on local "webrole" or in "blob" storage.')
->end()
->end()
->scalarNode('id')->end()
->scalarNode('connection_name')->end()
->end()
->end()
->arrayNode('federations')
->useAttributeAsKey('name')
->prototype('array')
->children()
->scalarNode('federationName')->isRequired()->end()
->scalarNode('distributionKey')->isRequired()->end()
->scalarNode('distributionType')->isRequired()->end()
->scalarNode('filteringEnabled')->defaultValue(false)->end()
->end()
->end()
->end()
->end();

return $treeBuilder;
}
}
Expand Down
Loading

0 comments on commit 540315c

Please sign in to comment.