8000 Remove the FWB configuration and rename the abstract decorator · symfony/symfony@99669ba · GitHub
[go: up one dir, main page]

Skip to content

Commit 99669ba

Browse files
committed
Remove the FWB configuration and rename the abstract decorator
1 parent 78c15c1 commit 99669ba

File tree

6 files changed

+37
-32
lines changed

6 files changed

+37
-32
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,6 @@ function ($a) {
10541054
->addDefaultsIfNotSet()
10551055
->children()
10561056
->booleanNode('default_middlewares')->defaultTrue()->end()
1057-
->scalarNode('decorator_class')->end()
10581057
->arrayNode('middlewares')
10591058
->defaultValue(array())
10601059
->prototype('scalar')->end()

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,13 +1481,8 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
14811481
throw new LogicException('The Validation middleware is only available when the Validator component is installed and enabled. Try running "composer require symfony/validator".');
14821482
}
14831483

1484-
$tagAttributes = array('name' => $name);
1485-
if (isset($bus['decorator_class'])) {
1486-
$tagAttributes['decorator_class'] = $bus['decorator_class'];
1487-
}
1488-
14891484
$container->setParameter($busId.'.middlewares', $middlewares);
1490-
$container->setDefinition($busId, (new Definition(MessageBus::class, array(array())))->addTag('messenger.bus', $tagAttributes));
1485+
$container->setDefinition($busId, (new Definition(MessageBus::class, array(array())))->addTag('messenger.bus', array('name' => $name)));
14911486

14921487
if ($name === $config['default_bus']) {
14931488
$container->setAlias('message_bus', $busId);

src/Symfony/Component/Messenger/DecoratedMessageBus.php renamed to src/Symfony/Component/Messenger/AbstractMessageBusDecorator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
/**
1515
* A decorated message bus.
1616
*
17-
* Use this abstract class to created your message bus decorator to specialise your
18-
* bus instances and type-hint them.
17+
* Use this abstract class to create your message bus decorator to specialise your
18+
* bus instances and type-hint against them.
1919
*
2020
* @author Samuel Roze <samuel.roze@gmail.com>
2121
*/
22-
abstract class DecoratedMessageBus implements MessageBusInterface
22+
abstract class AbstractMessageBusDecorator implements MessageBusInterface
2323
{
2424
private $decoratedBus;
2525

src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ public function process(ContainerBuilder $container)
6363
if ($container->hasDefinition('messenger.data_collector')) {
6464
$this->registerBusToCollector($container, $busId, $tags[0]);
6565
}
66-
67-
if (isset($tags[0]['decorator_class'])) {
68-
$container->register($tags[0]['decorator_class'], $tags[0]['decorator_class'])
69-
->setDecoratedService($busId)
70-
->setArguments(array(new Reference($tags[0]['decorator_class'].'.inner')));
71-
}
7266
}
7367

7468
$this->registerReceivers($container);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Messenger\Tests;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Messenger\AbstractMessageBusDecorator;
16+
use Symfony\Component\Messenger\MessageBusInterface;
17+
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
18+
19+
class AbstractMessageBusDecoratorTest extends TestCase
20+
{
21+
public function testItCanBeExtendedAndProxiesTheMessagesToTheBus()
22+
{
23+
$message = new DummyMessage('Foo');
24+
25+
$bus = $this->getMockBuilder(MessageBusInterface::class)->getMock();
26+
$bus->expects($this->once())->method('dispatch')->with($message)->willReturn('bar');
27+
28+
$this->assertSame('bar', (new CommandBus($bus))->dispatch($message));
29+
}
30+
}
31+
32+
class CommandBus extends AbstractMessageBusDecorator
33+
{}

src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Symfony\Component\Messenger\Adapter\AmqpExt\AmqpSender;
2121
use Symfony\Component\Messenger\ContainerHandlerLocator;
2222
use Symfony\Component\Messenger\DataCollector\MessengerDataCollector;
23-
use Symfony\Component\Messenger\DecoratedMessageBus;
2423
use Symfony\Component\Messenger\DependencyInjection\MessengerPass;
2524
use Symfony\Component\Messenger\Handler\ChainHandler;
2625
use Symfony\Component\Messenger\Handler\MessageSubscriberInterface;
@@ -261,17 +260,6 @@ public function testRegistersTraceableBusesToCollector()
261260
$this->assertEquals(array(array('registerBus', array('foo', new Reference($debuggedFooBusId))), array('registerBus', array('messenger.bus.bar', new Reference($debuggedBarBusId)))), $container->getDefinition('messenger.data_collector')->getMethodCalls());
262261
}
263262

264-
public function testRegistersBusDecoratedClass()
265-
{
266-
$container = $this->getContainerBuilder();
267-
$container->register($fooBusId = 'messenger.bus.foo', MessageBusInterface::class)->addTag('messenger.bus', array('decorator_class' => MyTypeHintedBus::class));
268-
269-
(new MessengerPass())->process($container);
270-
271-
$this->assertTrue($container->hasDefinition(MyTypeHintedBus::class));
272-
$this->assertSame(array($fooBusId, null, 0), $container->getDefinition(MyTypeHintedBus::class)->getDecoratedService());
273-
}
274-
275263
public function testRegistersMiddlewaresFromServices()
276264
{
277265
$container = $this->getContainerBuilder();
@@ -425,7 +413,3 @@ public function handle($message, callable $next)
425413
return $next($message);
426414
}
427415
}
428-
429-
final class MyTypeHintedBus extends DecoratedMessageBus
430-
{
431-
}

0 commit comments

Comments
 (0)
0