-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathSubscriptionRefreshCommand.php
More file actions
36 lines (29 loc) · 1.03 KB
/
SubscriptionRefreshCommand.php
File metadata and controls
36 lines (29 loc) · 1.03 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
<?php
declare(strict_types=1);
namespace Patchlevel\EventSourcing\Console\Command;
use LogicException;
use Patchlevel\EventSourcing\Subscription\Engine\CanRefreshSubscriptions;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use function sprintf;
#[AsCommand(
'event-sourcing:subscription:refresh',
'Refresh subscriptions (run-mode, group)',
)]
final class SubscriptionRefreshCommand extends SubscriptionCommand
{
protected function execute(InputInterface $input, OutputInterface $output): int
{
if (!$this->engine instanceof CanRefreshSubscriptions) {
throw new LogicException(sprintf(
'"%s" does not implement "%s" and cannot call refresh.',
$this->engine::class,
CanRefreshSubscriptions::class,
));
}
$criteria = $this->subscriptionEngineCriteria($input);
$this->engine->refresh($criteria);
return 0;
}
}