for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the OneGuard DynamicConfigurationBundle.
*
* (c) OneGuard <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace OneGuard\Bundle\DynamicConfigurationBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class Configuration implements ConfigurationInterface {
public function getConfigTreeBuilder() {
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('one_guard_dynamic_configuration');
$rootNode
->addDefaultsIfNotSet()
->children()
->arrayNode('definitions')
->prototype('array')
->enumNode('type')
->values(['entity', 'string'])
->isRequired()
->end()
->arrayNode('options')
->scalarNode('class')
->validate()
->ifTrue(function ($class) {
return !class_exists($class);
})
->thenInvalid("Class doesn't exist.")
->scalarNode('choice_label')->end()
// ->validate()
// ->ifTrue(function ($options) {
// if (!empty($options['class'])) {
// $propertyAccessor = new PropertyAccessor();
// return !$propertyAccessor->isReadable($options['class'], $options['choice_label']);
// }
// return true;
// })
// ->thenInvalid("Property not accessible.")
// ->end()
->scalarNode('translation_domain')
->defaultValue('messages')
->cannotBeEmpty()
->scalarNode('translation_prefix')
->defaultValue('')
->end();
return $treeBuilder;
}