@@ -59,24 +59,40 @@ protected function configureListFields(ListMapper $listMapper)
59
59
protected function configureFormFields (FormMapper $ formMapper )
60
60
{
61
61
$ formMapper
62
- ->with ('form.group_general ' )
63
- ->add (
64
- 'parent ' ,
65
- 'doctrine_phpcr_odm_tree ' ,
66
- array ('choice_list ' => array (), 'select_root_node ' => true , 'root_node ' => $ this ->routeRoot )
67
- )
68
- ->add ('name ' , 'text ' )
62
+ ->with ('form.group_general ' , array (
63
+ 'translation_domain ' => 'CmfRoutingBundle ' ,
64
+ ))
65
+ ->add (
66
+ 'parent ' ,
67
+ 'doctrine_phpcr_odm_tree ' ,
68
+ array ('choice_list ' => array (), 'select_root_node ' => true , 'root_node ' => $ this ->routeRoot )
69
+ )
70
+ ->add ('name ' , 'text ' )
69
71
->end ();
70
72
71
73
if (null === $ this ->getParentFieldDescription ()) {
72
74
$ formMapper
73
- ->with ('form.group_general ' )
75
+ ->with ('form.group_general ' , array (
76
+ 'translation_domain ' => 'CmfRoutingBundle ' ,
77
+ ))
74
78
->add ('content ' , 'doctrine_phpcr_odm_tree ' , array ('choice_list ' => array (), 'required ' => false , 'root_node ' => $ this ->contentRoot ))
75
79
->end ()
76
- ->with ('form.group_advanced ' )
80
+ ->with ('form.group_advanced ' , array (
81
+ 'translation_domain ' => 'CmfRoutingBundle ' ,
82
+ ))
77
83
->add ('variablePattern ' , 'text ' , array ('required ' => false ), array ('help ' => 'form.help_variable_pattern ' ))
78
- ->add ('defaults ' , 'sonata_type_immutable_array ' , array ('keys ' => $ this ->configureFieldsForDefaults ()))
79
- ->add ('options ' , 'sonata_type_immutable_array ' , array ('keys ' => $ this ->configureFieldsForOptions ()), array ('help ' => 'form.help_options ' ))
84
+ ->add (
85
+ 'defaults ' ,
86
+ 'sonata_type_immutable_array ' ,
87
+ array ('keys ' => $ this ->configureFieldsForDefaults ($ this ->getSubject ()->getDefaults ()))
88
+ )
89
+ ->add (
90
+ 'options ' ,
91
+ 'sonata_type_immutable_array ' ,
92
+ array (
93
+ 'keys ' => $ this ->configureFieldsForOptions ($ this ->getSubject ()->getOptions ())),
94
+ array ('help ' => 'form.help_options ' )
95
+ )
80
96
->end ()
81
97
->end ();
82
98
}
@@ -110,7 +126,14 @@ public function getExportFormats()
110
126
return array ();
111
127
}
112
128
113
- protected function configureFieldsForDefaults ()
129
+ /**
130
+ * Provide default route defaults and extract defaults from $dynamicDefaults.
131
+ *
132
+ * @param array $dynamicDefaults
133
+ *
134
+ * @return array Value for sonata_type_immutable_array
135
+ */
136
+ protected function configureFieldsForDefaults ($ dynamicDefaults )
114
137
{
115
138
$ defaults = array (
116
139
'_controller ' => array ('_controller ' , 'text ' , array ('required ' => false )),
@@ -121,14 +144,13 @@ protected function configureFieldsForDefaults()
121
144
)),
122
145
);
123
146
124
- $ dynamicDefaults = $ this ->getSubject ()->getDefaults ();
125
147
foreach ($ dynamicDefaults as $ name => $ value ) {
126
148
if (!isset ($ defaults [$ name ])) {
127
149
$ defaults [$ name ] = array ($ name , 'text ' , array ('required ' => false ));
128
150
}
129
151
}
130
152
131
- //parse variable pattern and add defaults for it - taken from routecompiler
153
+ //parse variable pattern and add defaults for tokens - taken from routecompiler
132
154
/** @var $route Route */
133
155
$ route = $ this ->subject ;
134
156
if ($ route && $ route ->getVariablePattern ()) {
@@ -144,15 +166,21 @@ protected function configureFieldsForDefaults()
144
166
return $ defaults ;
145
167
}
146
168
147
- protected function configureFieldsForOptions ()
169
+ /**
170
+ * Provide default options and extract options from $dynamicOptions.
171
+ *
172
+ * @param array $dynamicOptions
173
+ *
174
+ * @return array Value for sonata_type_immutable_array
175
+ */
176
+ protected function configureFieldsForOptions (array $ dynamicOptions )
148
177
{
149
178
$ options = array (
150
- array ('add_locale_pattern ' , 'checkbox ' , array ('required ' => false , 'label ' => 'form.label_add_locale_pattern ' , 'translation_domain ' => $ this -> translationDomain )),
151
- array ('add_format_pattern ' , 'checkbox ' , array ('required ' => false , 'label ' => 'form.label_add_format_pattern ' , 'translation_domain ' => $ this -> translationDomain )),
152
- array ('add_trailing_slash ' , 'checkbox ' , array ('required ' => false , 'label ' => 'form.label_add_trailing_slash ' , 'translation_domain ' => $ this -> translationDomain )),
179
+ ' add_locale_pattern ' => array ('add_locale_pattern ' , 'checkbox ' , array ('required ' => false , 'label ' => 'form.label_add_locale_pattern ' , 'translation_domain ' => ' CmfRoutingBundle ' )),
180
+ ' add_format_pattern ' => array ('add_format_pattern ' , 'checkbox ' , array ('required ' => false , 'label ' => 'form.label_add_format_pattern ' , 'translation_domain ' => ' CmfRoutingBundle ' )),
181
+ ' add_trailing_slash ' => array ('add_trailing_slash ' , 'checkbox ' , array ('required ' => false , 'label ' => 'form.label_add_trailing_slash ' , 'translation_domain ' => ' CmfRoutingBundle ' )),
153
182
);
154
183
155
- $ dynamicOptions = $ this ->getSubject ()->getOptions ();
156
184
foreach ($ dynamicOptions as $ name => $ value ) {
157
185
if (!isset ($ options [$ name ])) {
158
186
$ options [$ name ] = array ($ name , 'text ' , array ('required ' => false ));
0 commit comments