-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConsole.php
More file actions
43 lines (36 loc) · 1.15 KB
/
Console.php
File metadata and controls
43 lines (36 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
namespace Mailer\Application;
use DI\Container;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Application;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Messenger\Command\ConsumeMessagesCommand;
use Symfony\Component\Messenger\RoutableMessageBus;
use Symfony\Component\Messenger\Transport\TransportInterface;
final class Console extends Application
{
private string $receiverName = 'consumer';
public function __construct(
private RoutableMessageBus $bus,
private LoggerInterface $logger,
private TransportInterface $transport
) {
$this->addCommands([
$this->getConsumeCommand(),
]);
parent::__construct();
}
private function getConsumeCommand(): ConsumeMessagesCommand
{
$receiversContainer = new Container();
$receiversContainer->set($this->receiverName, $this->transport);
return new ConsumeMessagesCommand(
$this->bus,
$receiversContainer,
new EventDispatcher(),
$this->logger,
[$this->receiverName],
);
}
}