Skip to content

Commit 478ef55

Browse files
committed
fix cs & update docs
1 parent 782a7aa commit 478ef55

4 files changed

Lines changed: 16 additions & 26 deletions

File tree

docs/pages/configuration.md

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -413,22 +413,8 @@ patchlevel_event_sourcing:
413413

414414
## Command Bus
415415

416-
You can also enable and register our handlers in symfony messenger.
417-
These handlers allow you to use your aggregates as command handlers.
418-
419-
```yaml
420-
patchlevel_event_sourcing:
421-
command_bus: ~
422-
```
423-
!!! note
424-
425-
You can find out more about the command bus integration [here](https://event-sourcing.patchlevel.io/latest/command_bus/).
426-
427-
Default the handlers will be registered for all buses.
428-
You can also specify a specific bus.
429-
Before you have to define the bus in the messenger configuration.
430-
431-
### Symfony Messenger
416+
You can enable the command bus integration to use your aggregates as command handlers.
417+
For this bundle we provide only a symfony messenger integration, so you have to define the bus in the messenger configuration.
432418

433419
```yaml
434420
framework:
@@ -437,18 +423,19 @@ framework:
437423
buses:
438424
command.bus: ~
439425
```
440-
!!! tip
441-
442-
This is also useful if you have a event bus and a command bus.
443-
444-
And then you can specify the bus in the configuration.
426+
After this, you need to define the command bus in the event sourcing configuration.
427+
This will automatically register the aggregate handlers for the symfony messenger,
428+
so you can handle commands with your aggregates.
445429

446430
```yaml
447431
patchlevel_event_sourcing:
448432
command_bus:
449433
service: command.bus
450434
```
435+
!!! note
451436

437+
You can find out more about the command bus and the aggregate handlers [here](https://event-sourcing.patchlevel.io/latest/command_bus/).
438+
452439
## Event Bus
453440

454441
You can enable the event bus to listen for events and messages synchronously.

src/CommandBus/SymfonyCommandBus.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Patchlevel\EventSourcingBundle\CommandBus;
46

57
use Patchlevel\EventSourcing\CommandBus\CommandBus;
@@ -16,4 +18,4 @@ public function dispatch(object $command): void
1618
{
1719
$this->messageBus->dispatch($command);
1820
}
19-
}
21+
}

src/DependencyInjection/Configuration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* @psalm-type Config = array{
1212
* event_bus: array{enabled: bool, type: string, service: string},
13-
* command_bus: array{enabled: bool, message_bus: string},
13+
* command_bus: array{enabled: bool, service: string},
1414
* subscription: array{
1515
* store: array{type: string, service: string|null},
1616
* retry_strategy: array{base_delay: int, delay_factor: int, max_attempts: int},
@@ -237,7 +237,7 @@ public function getConfigTreeBuilder(): TreeBuilder
237237
->canBeEnabled()
238238
->addDefaultsIfNotSet()
239239
->children()
240-
->scalarNode('service')->defaultNull()->end()
240+
->scalarNode('service')->isRequired()->end()
241241
->booleanNode('register_aggregate_handlers')->defaultTrue()->end()
242242
->end()
243243
->end()

src/DependencyInjection/PatchlevelEventSourcingExtension.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
138138
use Symfony\Component\DependencyInjection\Extension\Extension;
139139
use Symfony\Component\DependencyInjection\Reference;
140+
140141
use function class_exists;
141142
use function sprintf;
142143

@@ -235,7 +236,7 @@ private function configureCommandBus(array $config, ContainerBuilder $container)
235236

236237
$container->setParameter(
237238
'patchlevel_event_sourcing.aggregate_handlers.bus',
238-
$config['command_bus']['service']
239+
$config['command_bus']['service'],
239240
);
240241

241242
return;
@@ -247,7 +248,7 @@ private function configureCommandBus(array $config, ContainerBuilder $container)
247248

248249
$container->setParameter(
249250
'patchlevel_event_sourcing.aggregate_handlers.bus',
250-
$config['aggregate_handlers']['bus']
251+
$config['aggregate_handlers']['bus'],
251252
);
252253
}
253254

0 commit comments

Comments
 (0)