Answer the question
In order to leave comments, you need to log in
Hydration of an entity from a request. What to use?
Hello.
Briefly: there is a legacy project in which Symfony components are embedded. There is Doctrine and Request.
Is there any builder that can put data into an entity from Request POST?
To avoid writing $entity->setName, setText and so on every time.
The data is essentially all simple, strings, yes numbers.
It seems that symfony/forms can do this, but we already have the layout of the forms.
Thanks to all.
Answer the question
In order to leave comments, you need to log in
Use Symfony Serializer Component , namely built-in ObjectNormalizer
or GetSetMethodNormalizer
, once you decide to work with entities through setters / getters
$obj = $this->normalizer->denormalize($data, YourEntity::class);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question