[Chapter7] Improvements

This commit is contained in:
Carlos Buenosvinos
2022-03-01 23:24:09 +01:00
parent b983344900
commit 947e1450c1
2 changed files with 49 additions and 25 deletions

View File

@@ -76,32 +76,33 @@ services:
- { name: messenger.message_handler, bus: query.bus }
# CHAPTER 6
Cheeper\Chapter6\Infrastructure\:
resource: '../src/Cheeper/Chapter6/Infrastructure/**/*.php'
Cheeper\Chapter6\:
resource: '../src/Cheeper/Chapter6/*'
Cheeper\Chapter6\Application\Author\Projection\CountFollowersProjectionHandler: ~
Cheeper\Chapter6\Application\Author\Command\WithDomainEvents\FollowCommandHandler:
chapter6_command_handlers:
namespace: Cheeper\Chapter6\Application\
resource: '../src/Cheeper/Chapter6/Application/**/*CommandHandler.php'
tags:
- { name: messenger.message_handler, bus: command.bus }
class: 'Cheeper\Chapter6\Application\Author\Command\WithDomainEvents\FollowCommandHandler'
Cheeper\Chapter6\Infrastructure\Application\Author\Projection\SymfonyCountFollowersProjector:
tags:
- { name: messenger.message_handler, bus: command.bus }
arguments:
- '@Cheeper\Chapter6\Application\Author\Projection\CountFollowersProjectionHandler'
# Cheeper\Chapter6\Infrastructure\:
# resource: '../src/Cheeper/Chapter6/Infrastructure/**/*.php'
#
# Cheeper\Chapter6\:
# resource: '../src/Cheeper/Chapter6/*'
#
# Cheeper\Chapter6\Application\Author\Command\WithDomainEvents\FollowCommandHandler:
# tags:
# - { name: messenger.message_handler, bus: command.bus }
# class: 'Cheeper\Chapter6\Application\Author\Command\WithDomainEvents\FollowCommandHandler'
#
# Cheeper\Chapter6\Infrastructure\Application\Author\Projection\SymfonyAuthorFollowedEventHandler:
# tags:
# - { name: messenger.message_handler, bus: event.bus }
# class: 'Cheeper\Chapter6\Infrastructure\Application\Author\Projection\SymfonyAuthorFollowedEventHandler'
Cheeper\Chapter6\Infrastructure\Application\Author\Projection\SymfonyAuthorFollowedHandler:
tags:
- { name: messenger.message_handler, bus: event.bus }
class: 'Cheeper\Chapter6\Infrastructure\Application\Author\Projection\SymfonyAuthorFollowedHandler'
# Cheeper\Chapter6\Application\EventBus:
# class: 'Cheeper\Chapter6\Infrastructure\Application\SymfonyEventBus'
Cheeper\Chapter6\Application\EventBus:
class: 'Cheeper\Chapter6\Infrastructure\Application\SymfonyEventBus'
# Cheeper\Chapter6\Application\ProjectionBus:
# class: 'Cheeper\Chapter6\Infrastructure\Application\SymfonyProjectionBus'
# CHAPTER 7
Cheeper\Chapter7\:
@@ -157,8 +158,4 @@ services:
- name: "doctrine.orm.entity_listener"
event: "postPersist"
entity: 'App\Entity\User'
Elasticsearch\Client:
factory: [ 'Elasticsearch\ClientBuilder', fromConfig ]
arguments: [ '%elasticsearch_config%' ]
#end-ignore

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Cheeper\Chapter6\Infrastructure\Application;
use Cheeper\Chapter6\Application\Projection;
use Cheeper\Chapter6\Application\ProjectionBus;
use Symfony\Component\Messenger\HandleTrait;
use Symfony\Component\Messenger\MessageBusInterface;
//snippet symfony-projection-bus
final class SymfonyProjectionBus implements ProjectionBus
{
use HandleTrait;
public function __construct(MessageBusInterface $projectionBus)
{
$this->messageBus = $projectionBus;
}
public function project(Projection $projection): void
{
$this->messageBus->dispatch($projection);
}
}
//end-snippet