S
S
siller4442018-07-23 16:38:17
symfony
siller444, 2018-07-23 16:38:17

How to properly filter and map data when implementing an API in Symfony?

Good day!
A question arose, or rather a couple of questions:
- how to properly validate (filter) data from a request without a Form component - how to map data to entities without using
JMSSerializerBundle

no one for some reason offered alternative solutions.

I would be grateful for any ideas, links. Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2018-07-23
@siller444

1. symfony/validator
2.symfony /serializer

$dto = $this->get('serializer')->deserialize(
    $request->getContent(),
    DTO::class
);

All this can be beautifully wrapped in Action Argument Resolving , thus. the code will look something like
public function editAction(DTO $dto)
{

}

where $dto will already have a valid object

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question