Skip to content

Commit 48dbeb8

Browse files
authored
Merge pull request #35 from norkunas/hub-aliases
Register aliases with hub name
2 parents e873c90 + 20876dc commit 48dbeb8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/DependencyInjection/MercureExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public function load(array $configs, ContainerBuilder $container)
8787

8888
$publishers[$name] = new Reference("$hubId.traceable");
8989
}
90+
91+
$container->registerAliasForArgument($hubId, PublisherInterface::class, "{$name}Publisher");
9092
}
9193

9294
if ($enableProfiler) {

tests/DependencyInjection/MercureExtensionTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public function testExtension()
3232
'url' => 'https://demo.mercure.rocks/hub',
3333
'jwt' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.HB0k08BaV8KlLZ3EafCRlTDGbkd9qdznCzJQ_l8ELTU',
3434
],
35+
[
36+
'name' => 'managed',
37+
'url' => 'https://demo.mercure.rocks/managed',
38+
'jwt' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.HB0k08BaV8KlLZ3EafCRlTDGbkd9qdznCzJQ_l8ELTU',
39+
],
3540
],
3641
],
3742
];
@@ -44,7 +49,9 @@ public function testExtension()
4449
$this->assertSame('https://demo.mercure.rocks/hub', $container->getDefinition('mercure.hub.default.publisher')->getArgument(0));
4550
$this->assertArrayHasKey('mercure.publisher', $container->getDefinition('mercure.hub.default.publisher')->getTags());
4651
$this->assertSame('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.HB0k08BaV8KlLZ3EafCRlTDGbkd9qdznCzJQ_l8ELTU', $container->getDefinition('mercure.hub.default.jwt_provider')->getArgument(0));
47-
$this->assertSame(['default' => 'https://demo.mercure.rocks/hub'], $container->getParameter('mercure.hubs'));
52+
$this->assertSame(['default' => 'https://demo.mercure.rocks/hub', 'managed' => 'https://demo.mercure.rocks/managed'], $container->getParameter('mercure.hubs'));
4853
$this->assertSame('https://demo.mercure.rocks/hub', $container->getParameter('mercure.default_hub'));
54+
$this->assertArrayHasKey('Symfony\Component\Mercure\PublisherInterface $defaultPublisher', $container->getAliases());
55+
$this->assertArrayHasKey('Symfony\Component\Mercure\PublisherInterface $managedPublisher', $container->getAliases());
4956
}
5057
}

0 commit comments

Comments
 (0)