[Question] Item instead of View
Closed this issue · 1 comments
Hi,
first of all - thanks für the boilerplate. I begin to get a hang on it.
If I use the QueryBus like $this->queryBus->ask(new FindByEmailQuery($email));
the result is a Item
Object with type UserView
.
I can't figure out how to get the UserView
out of it. I can access the array keys in the resource
but I dont think this is how you should access them. What do I miss?
TIA
Ludwig
Hi!
This use case doesn't return an Hydrated UserView
but an array. You can look at the handler: https://github.com/jorge07/symfony-5-es-cqrs-boilerplate/blob/symfony-5/src/App/User/Application/Query/User/FindByEmail/FindByEmailHandler.php#L29
The reason is that the read model is already optimised for the purpose so there's no need to have a custom class for it so you can return literals in an associative array and skip the hydration cost.
If for your needs you need to return a UserView
object, there's absolutely no need for you to return an Item
but any other thing you need and convert it into openApi spec later on in the controller.