From 6ed6307669578c86fc27adc47a249a7c18f22976 Mon Sep 17 00:00:00 2001 From: Dominik Garbulski Date: Thu, 6 May 2021 08:17:03 +0200 Subject: [PATCH] middleware change --- adr/2021_05_06_command_bus_unification.md | 19 +++---------------- .../Resources/config/app/config.yaml | 12 ++++++++---- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/adr/2021_05_06_command_bus_unification.md b/adr/2021_05_06_command_bus_unification.md index 8e000096fe..036489d0e2 100644 --- a/adr/2021_05_06_command_bus_unification.md +++ b/adr/2021_05_06_command_bus_unification.md @@ -5,20 +5,7 @@ ## Context and Problem Statement -We had 7 different names of buses across all sylius products, we decided to unify them. +Sylius and any other following product (like plugins) should utilize `sylius.command_bus` for command dispatching and `sylius.event_bus` for events. -## Considered Options - -### Leaving different buses as it was till now - -* Good, because it doesnt require much work -* Bad, because we need to keep track of all available buses - -### Unifying buses across all products - -* Good, because we will have only few buses to keep track of -* Bad, because potential bc break - -## Decision Outcome - -Chosen option: Unifying buses across all products, it allows us stick to one bus naming style +Take into account, that the command bus requires to have one corresponding handler for each message dispatched in contradiction to the event bus(where there is no such requirement). +In addition, the command bus will perform command validation and wrap the following handler within a transaction and flush to the database. diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/app/config.yaml b/src/Sylius/Bundle/ApiBundle/Resources/config/app/config.yaml index 9151a08eeb..ed894e1056 100644 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/app/config.yaml +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/app/config.yaml @@ -34,19 +34,23 @@ framework: messenger: buses: sylius.command_bus: &command_bus - default_middleware: allow_no_handlers + middleware: + - 'validation' + - 'doctrine_transaction' sylius.event_bus: &event_bus - default_middleware: allow_no_handlers + middleware: + - 'validation' + - 'doctrine_transaction' sylius_default.bus: *command_bus sylius_event.bus: *event_bus services: sylius_default.bus: deprecated: 'The "%service_id%" service alias is deprecated.' - synthetic: true + abstract: true sylius_event.bus: deprecated: 'The "%service_id%" service alias is deprecated.' - synthetic: true + abstract: true lexik_jwt_authentication: token_extractors: