Skip to content

Commit 226feeb

Browse files
committed
feature #1973 Allow overwriting rules in configuration (alcaeus)
This PR was merged into the 2.4-dev branch. Discussion ---------- Allow overwriting rules in configuration rebased version of #1613 Commits ------- f467c32 Allow overwriting rules in configuration
2 parents 558b149 + f467c32 commit 226feeb

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ private function addFormatListenerSection(ArrayNodeDefinition $rootNode)
339339
->children()
340340
->scalarNode('service')->defaultNull()->end()
341341
->arrayNode('rules')
342-
->cannotBeOverwritten()
342+
->performNoDeepMerging()
343343
->prototype('array')
344344
->fixXmlConfig('priority', 'priorities')
345345
->fixXmlConfig('attribute', 'attributes')

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,54 @@ public function testLoadBadCodesClassThrowsException()
150150
);
151151
}
152152

153+
public function testOverwriteFormatListenerRulesDoesNotMerge()
154+
{
155+
$configuration = $this->processor->processConfiguration(
156+
$this->configuration,
157+
[
158+
[
159+
'format_listener' => [
160+
'rules' => [
161+
[
162+
'path' => '^/admin',
163+
'priorities' => ['html'],
164+
],
165+
[
166+
'path' => '^/',
167+
'priorities' => ['html', 'json'],
168+
],
169+
],
170+
],
171+
],
172+
[
173+
'format_listener' => [
174+
'rules' => [
175+
[
176+
'path' => '^/',
177+
'priorities' => ['json'],
178+
],
179+
],
180+
],
181+
],
182+
]
183+
);
184+
185+
$expected = [
186+
[
187+
'path' => '^/',
188+
'priorities' => ['json'],
189+
'host' => null,
190+
'methods' => null,
191+
'attributes' => [],
192+
'stop' => false,
193+
'prefer_extension' => true,
194+
'fallback_format' => 'html',
195+
],
196+
];
197+
198+
$this->assertEquals($expected, $configuration['format_listener']['rules']);
199+
}
200+
153201
/**
154202
* incorrectExceptionCodeProvider.
155203
*

0 commit comments

Comments
 (0)