|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace JD\FormBundle\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
|
6
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
7
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* |
|
11
|
|
|
*/ |
|
12
|
|
|
final class Configuration implements ConfigurationInterface |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* Generates the configuration tree builder. |
|
16
|
|
|
* |
|
17
|
|
|
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder |
|
18
|
|
|
*/ |
|
19
|
|
|
public function getConfigTreeBuilder() |
|
20
|
|
|
{ |
|
21
|
|
|
$treeBuilder = new TreeBuilder(); |
|
22
|
|
|
$rootNode = $treeBuilder |
|
23
|
|
|
->root('jd_form') |
|
24
|
|
|
->addDefaultsIfNotSet() |
|
25
|
|
|
->canBeDisabled(); |
|
26
|
|
|
|
|
27
|
|
|
$this->addFormTypeSection($rootNode); |
|
28
|
|
|
|
|
29
|
|
|
return $treeBuilder; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param ArrayNodeDefinition $rootNode |
|
34
|
|
|
*/ |
|
35
|
|
|
private function addFormTypeSection(ArrayNodeDefinition $rootNode) |
|
36
|
|
|
{ |
|
37
|
|
|
$rootNode |
|
38
|
|
|
->children() |
|
39
|
|
|
->arrayNode('form') |
|
40
|
|
|
->info('Define the form types you want to use and their default options') |
|
41
|
|
|
->addDefaultsIfNotSet() |
|
42
|
|
|
->canBeDisabled() |
|
43
|
|
|
->children() |
|
44
|
|
|
->arrayNode('array') |
|
45
|
|
|
->info('The type array allow you to display (hidden or text) a collection of value with a separator') |
|
46
|
|
|
->addDefaultsIfNotSet() |
|
47
|
|
|
->canBeDisabled() |
|
48
|
|
|
->children() |
|
49
|
|
|
->scalarNode('delimiter') |
|
50
|
|
|
->info('Define the default delimiter used between two items') |
|
51
|
|
|
->defaultValue(', ') |
|
52
|
|
|
->end() |
|
53
|
|
|
->end() |
|
54
|
|
|
->end() |
|
55
|
|
|
->arrayNode('date') |
|
56
|
|
|
->info('The goal of this type is to have a default behaviour for all your date forms') |
|
57
|
|
|
->addDefaultsIfNotSet() |
|
58
|
|
|
->canBeDisabled() |
|
59
|
|
|
->children() |
|
60
|
|
|
->scalarNode('format') |
|
61
|
|
|
->info('@see http://symfony.com/doc/current/reference/forms/types/date.html#format') |
|
62
|
|
|
->defaultValue('dd/MM/yyyy') |
|
63
|
|
|
->end() |
|
64
|
|
|
->scalarNode('widget') |
|
65
|
|
|
->info('@see http://symfony.com/doc/current/reference/forms/types/date.html#widget') |
|
66
|
|
|
->defaultValue('single_text') |
|
67
|
|
|
->end() |
|
68
|
|
|
->end() |
|
69
|
|
|
->end() |
|
70
|
|
|
->arrayNode('date_between') |
|
71
|
|
|
->info('The missing form type to declare a date interval') |
|
72
|
|
|
->addDefaultsIfNotSet() |
|
73
|
|
|
->canBeDisabled() |
|
74
|
|
|
->children() |
|
75
|
|
|
->scalarNode('from') |
|
76
|
|
|
->info('Define the type to use for the from clause') |
|
77
|
|
|
->defaultValue('jd_date') |
|
78
|
|
|
->end() |
|
79
|
|
|
->scalarNode('to') |
|
80
|
|
|
->info('Define the type to use for the to clause') |
|
81
|
|
|
->defaultValue('jd_date') |
|
82
|
|
|
->end() |
|
83
|
|
|
->end() |
|
84
|
|
|
->end() |
|
85
|
|
|
->end() |
|
86
|
|
|
->end(); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|