Skip to content

Commit 697b722

Browse files
committed
The message bus is accessible via its interface and within the controllers
1 parent 8c3c12e commit 697b722

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\HttpFoundation\RequestStack;
1919
use Symfony\Component\HttpFoundation\Session\SessionInterface;
2020
use Symfony\Component\HttpKernel\HttpKernelInterface;
21+
use Symfony\Component\Message\MessageBusInterface;
2122
use Symfony\Component\Routing\RouterInterface;
2223
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
2324
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
@@ -84,6 +85,7 @@ public static function getSubscribedServices()
8485
'security.token_storage' => '?'.TokenStorageInterface::class,
8586
'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class,
8687
'parameter_bag' => '?'.ContainerInterface::class,
88+
'message_bus' => '?'.MessageBusInterface::class,
8789
);
8890
}
8991
}

src/Symfony/Bundle/FrameworkBundle/Resources/config/message.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
<argument type="collection" /> <!-- Middlewares -->
1313
</service>
1414

15+
<service id="Symfony\Component\Message\MessageBusInterface" alias="message_bus" />
16+
17+
<!-- Logging -->
1518
<service id="message.middleware.debug.logging" class="Symfony\Component\Message\Debug\LoggingMiddleware">
1619
<argument type="service" id="logger" />
1720

src/Symfony/Component/Message/Handler/MessageHandlerCollection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public function __construct(array $handlers)
3737

3838
public function __invoke($message)
3939
{
40-
foreach ($this->handlers as $handler) {
41-
yield $handler($message);
42-
}
40+
return array_map(function ($handler) use ($message) {
41+
return $handler($message);
42+
}, $this->handlers);
4343
}
4444
}

0 commit comments

Comments
 (0)