Conditions | 1 |
Paths | 1 |
Total Lines | 50 |
Code Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
18 | public function getConfigTreeBuilder() { |
||
19 | $treeBuilder = new TreeBuilder(); |
||
20 | $rootNode = $treeBuilder->root('one_guard_dynamic_configuration'); |
||
21 | |||
22 | $rootNode |
||
23 | ->addDefaultsIfNotSet() |
||
24 | ->children() |
||
25 | ->arrayNode('definitions') |
||
26 | ->prototype('array') |
||
27 | ->children() |
||
28 | ->enumNode('type') |
||
29 | ->values(['entity', 'string']) |
||
30 | ->isRequired() |
||
31 | ->end() |
||
32 | ->arrayNode('options') |
||
33 | ->children() |
||
34 | ->scalarNode('class') |
||
35 | ->validate() |
||
36 | ->ifTrue(function ($class) { |
||
37 | return !class_exists($class); |
||
38 | }) |
||
39 | ->thenInvalid("Class doesn't exist.") |
||
40 | ->end() |
||
41 | ->end() |
||
42 | ->scalarNode('choice_label')->end() |
||
43 | ->end() |
||
44 | // ->validate() |
||
45 | // ->ifTrue(function ($options) { |
||
46 | // if (!empty($options['class'])) { |
||
47 | // $propertyAccessor = new PropertyAccessor(); |
||
48 | // return !$propertyAccessor->isReadable($options['class'], $options['choice_label']); |
||
49 | // } |
||
50 | // return true; |
||
51 | // }) |
||
52 | // ->thenInvalid("Property not accessible.") |
||
53 | // ->end() |
||
54 | ->end() |
||
55 | ->end() |
||
56 | ->end() |
||
57 | ->end() |
||
58 | ->scalarNode('translation_domain') |
||
59 | ->defaultValue('messages') |
||
60 | ->cannotBeEmpty() |
||
61 | ->end() |
||
62 | ->scalarNode('translation_prefix') |
||
63 | ->defaultValue('') |
||
64 | ->end() |
||
65 | ->end(); |
||
66 | |||
67 | return $treeBuilder; |
||
68 | } |
||
70 |