File tree Expand file tree Collapse file tree 2 files changed +94
-0
lines changed Expand file tree Collapse file tree 2 files changed +94
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Patchlevel \EventSourcing \Console \Command ;
6
+
7
+ use Patchlevel \EventSourcing \Console \OutputStyle ;
8
+ use Patchlevel \EventSourcing \Store \Store ;
9
+ use Patchlevel \EventSourcing \Store \SubscriptionStore ;
10
+ use Symfony \Component \Console \Attribute \AsCommand ;
11
+ use Symfony \Component \Console \Command \Command ;
12
+ use Symfony \Component \Console \Input \InputInterface ;
13
+ use Symfony \Component \Console \Output \OutputInterface ;
14
+
15
+ #[AsCommand(
16
+ 'event-sourcing:schema:subscription-setup ' ,
17
+ 'setup subscription (pub/sub) for store ' ,
18
+ )]
19
+ final class SchemaSubscriptionSetupCommand extends Command
20
+ {
21
+ public function __construct (
22
+ private readonly Store $ store ,
23
+ ) {
24
+ parent ::__construct ();
25
+ }
26
+
27
+ protected function execute (InputInterface $ input , OutputInterface $ output ): int
28
+ {
29
+ $ io = new OutputStyle ($ input , $ output );
30
+
31
+ if (!$ this ->store instanceof SubscriptionStore) {
32
+ $ io ->error ('store does not support subscriptions ' );
33
+
34
+ return 1 ;
35
+ }
36
+
37
+ if (!$ this ->store ->supportSubscription ()) {
38
+ $ io ->error ('store does not support subscriptions ' );
39
+
40
+ return 1 ;
41
+ }
42
+
43
+ $ this ->store ->setupSubscription ();
44
+
45
+ return 0 ;
46
+ }
47
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Patchlevel \EventSourcing \Console \Command ;
6
+
7
+ use Patchlevel \EventSourcing \Console \OutputStyle ;
8
+ use Patchlevel \EventSourcing \Store \Store ;
9
+ use Patchlevel \EventSourcing \Store \SubscriptionStore ;
10
+ use Symfony \Component \Console \Attribute \AsCommand ;
11
+ use Symfony \Component \Console \Command \Command ;
12
+ use Symfony \Component \Console \Input \InputInterface ;
13
+ use Symfony \Component \Console \Output \OutputInterface ;
14
+
15
+ #[AsCommand(
16
+ 'event-sourcing:schema:subscription-setup ' ,
17
+ 'setup subscription (pub/sub) for store ' ,
18
+ )]
19
+ final class SchemaSubscriptionSetupCommand extends Command
20
+ {
21
+ public function __construct (
22
+ private readonly Store $ store ,
23
+ ) {
24
+ parent ::__construct ();
25
+ }
26
+
27
+ protected function execute (InputInterface $ input , OutputInterface $ output ): int
28
+ {
29
+ $ io = new OutputStyle ($ input , $ output );
30
+
31
+ if (!$ this ->store instanceof SubscriptionStore) {
32
+ $ io ->error ('store does not support subscriptions ' );
33
+
34
+ return 1 ;
35
+ }
36
+
37
+ if (!$ this ->store ->supportSubscription ()) {
38
+ $ io ->error ('store does not support subscriptions ' );
39
+
40
+ return 1 ;
41
+ }
42
+
43
+ $ this ->store ->setupSubscription ();
44
+
45
+ return 0 ;
46
+ }
47
+ }
You can’t perform that action at this time.
0 commit comments