Skip to content

[Messenger] Rename tag attribute "name" by "alias" #27229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1511,8 +1511,8 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
$transportDefinition = (new Definition(TransportInterface::class))
->setFactory(array(new Reference('messenger.transport_factory'), 'createTransport'))
->setArguments(array($transport['dsn'], $transport['options']))
->addTag('messenger.receiver', array('name' => $name))
->addTag('messenger.sender', array('name' => $name))
->addTag('messenger.receiver', array('alias' => $name))
->addTag('messenger.sender', array('alias' => $name))
;
$container->setDefinition('messenger.transport.'.$name, $transportDefinition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@ public function testMessengerTransports()
$this->assertTrue($container->hasDefinition('messenger.transport.default'));
$this->assertTrue($container->getDefinition('messenger.transport.default')->hasTag('messenger.receiver'));
$this->assertTrue($container->getDefinition('messenger.transport.default')->hasTag('messenger.sender'));
$this->assertEquals(array(array('name' => 'default')), $container->getDefinition('messenger.transport.default')->getTag('messenger.receiver'));
$this->assertEquals(array(array('name' => 'default')), $container->getDefinition('messenger.transport.default')->getTag('messenger.sender'));
$this->assertEquals(array(array('alias' => 'default')), $container->getDefinition('messenger.transport.default')->getTag('messenger.receiver'));
$this->assertEquals(array(array('alias' => 'default')), $container->getDefinition('messenger.transport.default')->getTag('messenger.sender'));

$this->assertTrue($container->hasDefinition('messenger.transport.customised'));
$transportFactory = $container->getDefinition('messenger.transport.customised')->getFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function process(ContainerBuilder $container)
}

if ($container->hasDefinition('messenger.data_collector')) {
$this->registerBusToCollector($container, $busId, $tags[0]);
$this->registerBusToCollector($container, $busId);
}
}

Expand Down Expand Up @@ -177,8 +177,8 @@ private function registerReceivers(ContainerBuilder $container)
$receiverMapping[$id] = new Reference($id);

foreach ($tags as $tag) {
if (isset($tag['name'])) {
$receiverMapping[$tag['name']] = $receiverMapping[$id];
if (isset($tag['alias'])) {
$receiverMapping[$tag['alias']] = $receiverMapping[$id];
}
}
}
Expand All @@ -202,16 +202,16 @@ private function registerSenders(ContainerBuilder $container)
$senderLocatorMapping[$id] = new Reference($id);

foreach ($tags as $tag) {
if (isset($tag['name'])) {
$senderLocatorMapping[$tag['name']] = $senderLocatorMapping[$id];
if (isset($tag['alias'])) {
$senderLocatorMapping[$tag['alias']] = $senderLocatorMapping[$id];
}
}
}

$container->getDefinition('messenger.sender_locator')->replaceArgument(0, $senderLocatorMapping);
}

private function registerBusToCollector(ContainerBuilder $container, string $busId, array $tag)
private function registerBusToCollector(ContainerBuilder $container, string $busId)
{
$container->setDefinition(
$tracedBusId = 'debug.traced.'.$busId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function testGetClassesFromTheHandlerSubscriberInterface()
public function testItRegistersReceivers()
{
$container = $this->getContainerBuilder();
$container->register(AmqpReceiver::class, AmqpReceiver::class)->addTag('messenger.receiver', array('name' => 'amqp'));
$container->register(AmqpReceiver::class, AmqpReceiver::class)->addTag('messenger.receiver', array('alias' => 'amqp'));

(new MessengerPass())->process($container);

Expand All @@ -128,7 +128,7 @@ public function testItRegistersOneReceiverAndSetsTheDefaultOneOnTheCommand()
null,
));

$container->register(AmqpReceiver::class, AmqpReceiver::class)->addTag('messenger.receiver', array('name' => 'amqp'));
$container->register(AmqpReceiver::class, AmqpReceiver::class)->addTag('messenger.receiver', array('alias' => 'amqp'));

(new MessengerPass())->process($container);

Expand All @@ -145,8 +145,8 @@ public function testItRegistersMultipleReceiversAndDoesNotSetTheDefaultOneOnTheC
null,
));

$container->register(AmqpReceiver::class, AmqpReceiver::class)->addTag('messenger.receiver', array('name' => 'amqp'));
$container->register(DummyReceiver::class, DummyReceiver::class)->addTag('messenger.receiver', array('name' => 'dummy'));
$container->register(AmqpReceiver::class, AmqpReceiver::class)->addTag('messenger.receiver', array('alias' => 'amqp'));
$container->register(DummyReceiver::class, DummyReceiver::class)->addTag('messenger.receiver', array('alias' => 'dummy'));

(new MessengerPass())->process($container);

Expand All @@ -156,7 +156,7 @@ public function testItRegistersMultipleReceiversAndDoesNotSetTheDefaultOneOnTheC
public function testItRegistersSenders()
{
$container = $this->getContainerBuilder();
$container->register(AmqpSender::class, AmqpSender::class)->addTag('messenger.sender', array('name' => 'amqp'));
$container->register(AmqpSender::class, AmqpSender::class)->addTag('messenger.sender', array('alias' => 'amqp'));

(new MessengerPass())->process($container);

Expand Down