Skip to content

Commit 979580a

Browse files
HypeMCjderusse
authored andcommitted
Typo in console formatter option name
1 parent b9b322d commit 979580a

File tree

3 files changed

+106
-4
lines changed

3 files changed

+106
-4
lines changed

DependencyInjection/Configuration.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* - [verbosity_levels]: level => verbosity configuration
3939
* - [level]: level name or int value, defaults to DEBUG
4040
* - [bubble]: bool, defaults to true
41-
* - [console_formater_options]: array
41+
* - [console_formatter_options]: array
4242
*
4343
* - firephp:
4444
* - [level]: level name or int value, defaults to DEBUG
@@ -657,12 +657,19 @@ public function getConfigTreeBuilder()
657657
->end()
658658
// console
659659
->variableNode('console_formater_options')
660-
->defaultValue([])
660+
->setDeprecated('"%path%.%node%" is deprecated, use "%path%.console_formatter_options" instead.')
661661
->validate()
662662
->ifTrue(function ($v) {
663663
return !is_array($v);
664664
})
665-
->thenInvalid('console_formater_options must an array.')
665+
->thenInvalid('The console_formater_options must be an array.')
666+
->end()
667+
->end()
668+
->variableNode('console_formatter_options')
669+
->defaultValue([])
670+
->validate()
671+
->ifTrue(static function ($v) { return !is_array($v); })
672+
->thenInvalid('The console_formatter_options must be an array.')
666673
->end()
667674
->end()
668675
->arrayNode('verbosity_levels') // console
@@ -783,6 +790,18 @@ public function getConfigTreeBuilder()
783790
->scalarNode('formatter')->end()
784791
->booleanNode('nested')->defaultFalse()->end()
785792
->end()
793+
->beforeNormalization()
794+
->always(static function ($v) {
795+
if (empty($v['console_formatter_options']) && !empty($v['console_formater_options'])) {
796+
$v['console_formatter_options'] = $v['console_formater_options'];
797+
}
798+
799+
return $v;
800+
})
801+
->end()
802+
->validate()
803+
->always(static function ($v) { unset($v['console_formater_options']); return $v; })
804+
->end()
786805
->validate()
787806
->ifTrue(function ($v) { return 'service' === $v['type'] && !empty($v['formatter']); })
788807
->thenInvalid('Service handlers can not have a formatter configured in the bundle, you must reconfigure the service itself instead')

DependencyInjection/MonologExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
215215
null,
216216
$handler['bubble'],
217217
isset($handler['verbosity_levels']) ? $handler['verbosity_levels'] : [],
218-
$handler['console_formater_options']
218+
$handler['console_formatter_options']
219219
]);
220220
$definition->addTag('kernel.event_subscriber');
221221
break;

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ public function testWithNestedHandler()
361361

362362
$this->assertTrue($config['handlers']['foobar']['nested']);
363363
}
364+
364365
public function testWithRedisHandler()
365366
{
366367
$configs = [
@@ -406,6 +407,88 @@ public function testWithRedisHandler()
406407
$this->assertEquals('monolog_redis_test', $config['handlers']['redis']['redis']['key_name']);
407408
}
408409

410+
/**
411+
* @group legacy
412+
*/
413+
public function testConsoleFormatterOptionsRename()
414+
{
415+
$configs = [
416+
[
417+
'handlers' => [
418+
'old' => [
419+
'type' => 'console',
420+
'console_formater_options' => ['foo' => 'foo'],
421+
],
422+
'old2' => [
423+
'type' => 'console',
424+
'console_formater_options' => ['foo' => 'foo'],
425+
],
426+
'new' => [
427+
'type' => 'console',
428+
'console_formatter_options' => ['bar' => 'bar'],
429+
],
430+
'new2' => [
431+
'type' => 'console',
432+
'console_formatter_options' => ['bar' => 'bar'],
433+
],
434+
'both' => [
435+
'type' => 'console',
436+
'console_formater_options' => ['foo' => 'foo'],
437+
'console_formatter_options' => ['bar' => 'bar'],
438+
],
439+
'both2' => [
440+
'type' => 'console',
441+
'console_formater_options' => ['foo' => 'foo'],
442+
'console_formatter_options' => ['bar' => 'bar'],
443+
],
444+
],
445+
],
446+
[
447+
'handlers' => [
448+
'old2' => [
449+
'type' => 'console',
450+
'console_formater_options' => ['baz' => 'baz'],
451+
],
452+
'new2' => [
453+
'type' => 'console',
454+
'console_formatter_options' => ['qux' => 'qux'],
455+
],
456+
'both2' => [
457+
'type' => 'console',
458+
'console_formater_options' => ['baz' => 'baz'],
459+
'console_formatter_options' => ['qux' => 'qux'],
460+
],
461+
],
462+
],
463+
];
464+
465+
$config = $this->process($configs);
466+
467+
$this->assertArrayHasKey('console_formatter_options', $config['handlers']['old']);
468+
$this->assertSame(['foo' => 'foo'], $config['handlers']['old']['console_formatter_options']);
469+
$this->assertArrayNotHasKey('console_formater_options', $config['handlers']['old']);
470+
471+
$this->assertArrayHasKey('console_formatter_options', $config['handlers']['new']);
472+
$this->assertSame(['bar' => 'bar'], $config['handlers']['new']['console_formatter_options']);
473+
$this->assertArrayNotHasKey('console_formater_options', $config['handlers']['new']);
474+
475+
$this->assertArrayHasKey('console_formatter_options', $config['handlers']['both']);
476+
$this->assertSame(['bar' => 'bar'], $config['handlers']['both']['console_formatter_options']);
477+
$this->assertArrayNotHasKey('console_formater_options', $config['handlers']['both']);
478+
479+
$this->assertArrayHasKey('console_formatter_options', $config['handlers']['old2']);
480+
$this->assertSame(['baz' => 'baz'], $config['handlers']['old2']['console_formatter_options']);
481+
$this->assertArrayNotHasKey('console_formater_options', $config['handlers']['old2']);
482+
483+
$this->assertArrayHasKey('console_formatter_options', $config['handlers']['new2']);
484+
$this->assertSame(['qux' => 'qux'], $config['handlers']['new2']['console_formatter_options']);
485+
$this->assertArrayNotHasKey('console_formater_options', $config['handlers']['new2']);
486+
487+
$this->assertArrayHasKey('console_formatter_options', $config['handlers']['both2']);
488+
$this->assertSame(['qux' => 'qux'], $config['handlers']['both2']['console_formatter_options']);
489+
$this->assertArrayNotHasKey('console_formater_options', $config['handlers']['both2']);
490+
}
491+
409492
/**
410493
* Processes an array of configurations and returns a compiled version.
411494
*

0 commit comments

Comments
 (0)