for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Knp\DictionaryBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
final class Configuration implements ConfigurationInterface
{
/**
* @var string
*/
private const CONFIG_NAME = 'knp_dictionary';
public function getConfigTreeBuilder(): TreeBuilder
$treeBuilder = new TreeBuilder(self::CONFIG_NAME);
$nodeDefinition = $treeBuilder->getRootNode();
$nodeDefinition
->children()
->arrayNode('dictionaries')
->useAttributeAsKey('name')
->prototype('array')
->beforeNormalization()
->always()
->then(static function ($values) {
if (false === \array_key_exists('type', $values)) {
if (false === \array_key_exists('content', $values)) {
return ['type' => 'value', 'content' => $values];
}
return array_merge($values, ['type' => 'value']);
* @var non-empty-array<mixed> $values
return $values;
})
->end()
->scalarNode('type')->defaultValue('value')->end()
->scalarNode('extends')->end()
->normalizeKeys(false)->prototype('scalar')->end()
->arrayNode('content')
->scalarNode('service')->end()
->scalarNode('method')->end()
;
return $treeBuilder;