Skip to content

Commit a890ff2

Browse files
authored
Merge pull request #62 from tyrsson/refactor-target-config-keys
Refactor target config keys to CommandBusInteface::class
2 parents 3f1017f + 4c0ddda commit a890ff2

15 files changed

Lines changed: 51 additions & 46 deletions

docs/command-handler-factory.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ class CustomCommandProcessor
125125
The factory relies on command-to-handler mappings configured in your application:
126126

127127
```php
128-
// config/autoload/cmd-bus.global.php
128+
// config/autoload/commandbus.global.php
129129
return [
130-
Webware\CommandBus\ConfigProvider::class => [
130+
Webware\CommandBus\CommandBusInterface::class => [
131131
'command-map' => [
132132
App\Command\CreateUserCommand::class => App\Handler\CreateUserHandler::class,
133133
App\Command\UpdateUserCommand::class => App\Handler\UpdateUserHandler::class,
@@ -142,7 +142,7 @@ return [
142142
Handlers must be registered in the dependency injection container:
143143

144144
```php
145-
// config/autoload/dependencies.global.php
145+
// In a autoloaded config file or ConfigProvider
146146
return [
147147
'dependencies' => [
148148
'factories' => [

docs/commandbus-interface.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ The `CommandBusInterface` serves as:
2929
1. **Abstraction Layer** - Allows different command bus implementations
3030
2. **Dependency Injection Target** - Services can depend on the interface rather than concrete implementations
3131
3. **Type Safety** - Provides compile-time guarantees for command handling
32+
4. **CommandBusInterface::class** - Serves as the top level configuration key
3233

3334
## Usage Examples
3435

docs/config-provider.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ $aggregator = new ConfigAggregator([
6969
```php
7070
// config/autoload/cmd-bus.global.php
7171
return [
72-
Webware\CommandBus\ConfigProvider::class => [
72+
Webware\CommandBus\CommandBusInterface::class => [
7373
'command-map' => [
7474
// User management commands
7575
App\Command\User\CreateUserCommand::class => App\Handler\User\CreateUserHandler::class,

docs/container/commandbus-factory.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ try {
196196
The factory expects the middleware pipeline to be properly configured:
197197

198198
```php
199-
// config/autoload/cmd-bus.global.php
199+
// config/autoload/commandbus.global.php
200200
return [
201-
'Webware\CommandBus\ConfigProvider' => [
201+
CommandBusInterface::class => [
202202
'command-map' => [
203203
// Map command names to their handlers
204204
CreateUserCommand::class => CreateUserHandler::class,

docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $aggregator = new ConfigAggregator([
3030
use Webware\CommandBus\ConfigProvider;
3131

3232
return [
33-
ConfigProvider::class => [
33+
CommandBusInterface::class => [
3434
ConfigProvider::COMMAND_MAP_KEY => [
3535
App\User\Command\CreateUserCommand::class => App\User\CommandHandler\CreateUserHandler::class,
3636
App\User\Command\UpdateUserCommand::class => App\User\CommandHandler\UpdateUserHandler::class,

docs/middleware-pipe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Processes a command through the pipeline with a specific final handler.
5858

5959
**Returns:**
6060

61-
- `mixed` - The result from the pipeline execution
61+
- `CommandResultInterface` - The result from the pipeline execution
6262

6363
### pipe(MiddlewareInterface $middleware): void
6464

docs/middleware/command-handler-middleware.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ The middleware implements both `MiddlewareInterface` and `CommandHandlerInterfac
2929
### Command-Handler Mapping
3030

3131
```php
32-
// config/autoload/cmd-bus.global.php
32+
// config/autoload/commandbus.global.php
3333
return [
3434
// other config
35-
Webware\CommandBus\ConfigProvider::class => [
35+
Webware\CommandBus\CommandBusInterface::class => [
3636
'command-map' => [
3737
App\Command\CreateUserCommand::class => App\Handler\CreateUserHandler::class,
3838
App\Command\UpdateUserCommand::class => App\Handler\UpdateUserHandler::class,

docs/middleware/post-command-handler-middleware.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ final class ErrorHandlingPostCommandMiddleware extends PostCommandHandlerMiddlew
211211
### Adding to Middleware Pipeline
212212

213213
```php
214-
// config/autoload/cmd-bus.global.php
214+
// config/autoload/commandbus.global.php
215215
return [
216-
Webware\CommandBus\ConfigProvider::class => [
216+
Webware\CommandBus\CommandBusInterface::class => [
217217
'middleware-pipeline' => [
218218
// Pre-command middleware...
219219
[

docs/middleware/pre-command-handler-middleware.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ final class EnrichmentPreCommandMiddleware extends PreCommandHandlerMiddleware
124124
### Adding to Middleware Pipeline
125125

126126
```php
127-
// config/autoload/cmd-bus.global.php
127+
// config/autoload/commandbus.global.php
128128
return [
129-
Webware\CommandBus\ConfigProvider::class => [
129+
Webware\CommandBus\CommandBusInterface::class => [
130130
'middleware-pipeline' => [
131131
[
132132
'middleware' => App\Middleware\AuthenticationPreCommandMiddleware::class,

src/CommandHandlerResolver.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66

77
use Override;
88
use Psr\Container\ContainerInterface;
9+
use Webware\CommandBus\CommandBusInterface;
910
use Webware\CommandBus\CommandInterface;
1011
use Webware\CommandBus\ConfigProvider;
1112
use Webware\CommandBus\Exception\InvalidConfigurationException;
1213

1314
use function array_key_exists;
1415

1516
/**
16-
* @phpstan-import-type CmdBusConfig from ConfigProvider
17+
* @phpstan-import-type CommandBusConfig from ConfigProvider
1718
* @phpstan-import-type CommandMap from ConfigProvider
1819
*/
1920
final class CommandHandlerResolver implements CommandHandlerResolverInterface
@@ -31,10 +32,10 @@ public function __invoke(CommandInterface $command): CommandHandlerInterface
3132
#[Override]
3233
public function resolve(CommandInterface $command): CommandHandlerInterface
3334
{
34-
/** @phpstan-var array<CmdBusConfig> */
35+
/** @phpstan-var array<CommandBusConfig> */
3536
$config = $this->container->get('config');
36-
/** @phpstan-var CmdBusConfig $config */
37-
$config = $config[ConfigProvider::class] ?? [];
37+
/** @phpstan-var CommandBusConfig $config */
38+
$config = $config[CommandBusInterface::class] ?? [];
3839
/** @phpstan-var CommandMap $map */
3940
$map = $config[ConfigProvider::COMMAND_MAP_KEY] ?? [];
4041
if (! array_key_exists($command::class, $map)) {

0 commit comments

Comments
 (0)