File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
Tests/DependencyInjection Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,18 @@ private function addFormatListenerSection(ArrayNodeDefinition $rootNode)
201201 ->fixXmlConfig ('rule ' , 'rules ' )
202202 ->addDefaultsIfNotSet ()
203203 ->canBeUnset ()
204+ ->beforeNormalization ()
205+ ->ifTrue (function ($ v ) {
206+ // check if we got an assoc array in rules
207+ return isset ($ v ['rules ' ])
208+ && is_array ($ v ['rules ' ])
209+ && array_keys ($ v ['rules ' ]) !== range (0 , count ($ v ['rules ' ]) - 1 );
210+ })
211+ ->then (function ($ v ) {
212+ $ v ['rules ' ] = array ($ v ['rules ' ]);
213+ return $ v ;
214+ })
215+ ->end ()
204216 ->children ()
205217 ->arrayNode ('rules ' )
206218 ->cannotBeOverwritten ()
Original file line number Diff line number Diff line change @@ -167,6 +167,33 @@ public function testLoadFormatListenerWithDefaults()
167167 $ this ->assertFalse ($ this ->container ->hasDefinition ('fos_rest.format_listener ' ));
168168 }
169169
170+ public function testLoadFormatListenerWithSingleRule ()
171+ {
172+ $ config = array (
173+ 'fos_rest ' => array ('format_listener ' => array (
174+ 'rules ' => array ('path ' => '/ ' )
175+ )),
176+ );
177+ $ this ->extension ->load ($ config , $ this ->container );
178+
179+ $ this ->assertTrue ($ this ->container ->hasDefinition ('fos_rest.format_listener ' ));
180+ }
181+
182+ public function testLoadFormatListenerWithMultipleRule ()
183+ {
184+ $ config = array (
185+ 'fos_rest ' => array ('format_listener ' => array (
186+ 'rules ' => array (
187+ array ('path ' => '/foo ' ),
188+ array ('path ' => '/ ' )
189+ )
190+ )),
191+ );
192+ $ this ->extension ->load ($ config , $ this ->container );
193+
194+ $ this ->assertTrue ($ this ->container ->hasDefinition ('fos_rest.format_listener ' ));
195+ }
196+
170197 public function testLoadServicesWithDefaults ()
171198 {
172199 $ this ->extension ->load (array (), $ this ->container );
You can’t perform that action at this time.
0 commit comments