Validate that the message exists to be able to configure its routing
Uses an existing class in the tests... :) Only trigger the autoloading once
This commit is contained in:
parent
cef8d2823a
commit
04d87ca829
@ -1496,6 +1496,10 @@ class FrameworkExtension extends Extension
|
||||
|
||||
$messageToSenderIdsMapping = array();
|
||||
foreach ($config['routing'] as $message => $messageConfiguration) {
|
||||
if (!class_exists($message) && !interface_exists($message, false)) {
|
||||
throw new LogicException(sprintf('Messenger routing configuration contains a mistake: message "%s" does not exist. It needs to match an existing class or interface.', $message));
|
||||
}
|
||||
|
||||
$messageToSenderIdsMapping[$message] = $messageConfiguration['senders'];
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\FooMessage;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\BarMessage;
|
||||
|
||||
$container->loadFromExtension('framework', array(
|
||||
'messenger' => array(
|
||||
'routing' => array(
|
||||
'App\Bar' => array('sender.bar', 'sender.biz'),
|
||||
'App\Foo' => 'sender.foo',
|
||||
FooMessage::class => array('sender.bar', 'sender.biz'),
|
||||
BarMessage::class => 'sender.foo',
|
||||
),
|
||||
),
|
||||
));
|
||||
|
@ -7,11 +7,11 @@
|
||||
|
||||
<framework:config>
|
||||
<framework:messenger>
|
||||
<framework:routing message-class="App\Bar">
|
||||
<framework:routing message-class="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\FooMessage">
|
||||
<framework:sender service="sender.bar" />
|
||||
<framework:sender service="sender.biz" />
|
||||
</framework:routing>
|
||||
<framework:routing message-class="App\Foo">
|
||||
<framework:routing message-class="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\BarMessage">
|
||||
<framework:sender service="sender.foo" />
|
||||
</framework:routing>
|
||||
</framework:messenger>
|
||||
|
@ -1,5 +1,5 @@
|
||||
framework:
|
||||
messenger:
|
||||
routing:
|
||||
'App\Bar': ['sender.bar', 'sender.biz']
|
||||
'App\Foo': 'sender.foo'
|
||||
'Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\FooMessage': ['sender.bar', 'sender.biz']
|
||||
'Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\BarMessage': 'sender.foo'
|
||||
|
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger;
|
||||
|
||||
class BarMessage
|
||||
{
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger;
|
||||
|
||||
class FooMessage
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user