[EventDispatcher] Correct the called event listener method case
This commit is contained in:
parent
b1cf295bf8
commit
29b4b76416
@ -81,7 +81,7 @@ class RegisterListenersPass implements CompilerPassInterface
|
||||
|
||||
if (!isset($event['method'])) {
|
||||
$event['method'] = 'on'.preg_replace_callback([
|
||||
'/(?<=\b)[a-z]/i',
|
||||
'/(?<=\b|_)[a-z]/i',
|
||||
'/[^a-z0-9]/i',
|
||||
], function ($matches) { return strtoupper($matches[0]); }, $event['event']);
|
||||
$event['method'] = preg_replace('/[^a-z0-9]/i', '', $event['method']);
|
||||
|
@ -175,6 +175,7 @@ class RegisterListenersPassTest extends TestCase
|
||||
$container->register('foo', \stdClass::class)->addTag('kernel.event_listener', ['event' => 'foo.bar']);
|
||||
$container->register('bar', InvokableListenerService::class)->addTag('kernel.event_listener', ['event' => 'foo.bar']);
|
||||
$container->register('baz', InvokableListenerService::class)->addTag('kernel.event_listener', ['event' => 'event']);
|
||||
$container->register('zar', \stdClass::class)->addTag('kernel.event_listener', ['event' => 'foo.bar_zar']);
|
||||
$container->register('event_dispatcher', \stdClass::class);
|
||||
|
||||
$registerListenersPass = new RegisterListenersPass();
|
||||
@ -206,6 +207,14 @@ class RegisterListenersPassTest extends TestCase
|
||||
0,
|
||||
],
|
||||
],
|
||||
[
|
||||
'addListener',
|
||||
[
|
||||
'foo.bar_zar',
|
||||
[new ServiceClosureArgument(new Reference('zar')), 'onFooBarZar'],
|
||||
0,
|
||||
],
|
||||
],
|
||||
];
|
||||
$this->assertEquals($expectedCalls, $definition->getMethodCalls());
|
||||
}
|
||||
|
Reference in New Issue
Block a user