Welcome to crossword Discussions! #2
Replies: 5 comments
-
In terms of DDD how did Request objects and Twig extension end up in Application layer? In you deptrac you're not tracking vendor dependencies. Application and Domain layers should almost zero vendor dependencies. Only basic staff like webmozart/assert or uuid. |
Beta Was this translation helpful? Give feedback.
-
Actually what's the profit of using empty Request objects t all? it seems like just an useless extra layer of abstraction. Both of them will result in HTTP 500 for user. Which is unacceptable for validating user request. Request validation exceptions must provide HTTP 400 error at least, and clear per request attribute errors list (errors for all fields at once) at most. Which you can't implement using plain webmozart assertions. These assertions should be used mostly internally in domain layer. Requests should be validated on Presentation layer with something like symfony/validator. |
Beta Was this translation helpful? Give feedback.
-
Oh man... In fact you have infrastructure dependencies all around your domain and application... This is not DDD, as you are violating dependencies direction principle! Symfony Messenger in domain? this is absolutely from infrastructure. What you do with messenger should be done via some abstract To register message/event handlers you must not rely on Symony/messengers MessageHandlerInterface magic staff, but register your events in app's config by some domain EventHandlerInterface and messenger's service tag. use XXX\Core\Common\Application\EventDispatcherInterface;
use Symfony\Component\Messenger\MessageBusInterface;
/**
* Symfony Messenger adapter for Core event dispatcher
*/
class MessengerEventDispatcher implements EventDispatcherInterface
{
private MessageBusInterface $bus;
public function __construct(MessageBusInterface $bus)
{
$this->bus = $bus;
}
public function dispatch(object $event): void
{
$this->bus->dispatch($event);
}
} <?php
declare(strict_types=1);
namespace XXX\Core\Common\Application\Events;
/**
* All core event handlers should implement this interface.
* It can be used for handlers auto-configuration
*/
interface EventHandlerInterface
{
} # Register core event handlers
_instanceof:
XXX\Core\Common\Application\Events\EventHandlerInterface:
tags: [messenger.message_handler] |
Beta Was this translation helpful? Give feedback.
-
While arguable, I personally came to understanding that:
|
Beta Was this translation helpful? Give feedback.
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪.
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
Beta Was this translation helpful? Give feedback.
All reactions