Answer the question
In order to leave comments, you need to log in
How to handle mass update in api and controllers correctly?
If you edited one element, then everything is OK (PUT) some / id
But what if the entity elements on the form are edited in bulk?
Don't spam (PUT) some/id in a loop?
Surely start a separate rest, but how according to GOST should it sound like (PUT) some/mass-update with an array in the body? And the controller in the cycle should the service separately pull for each element from the body?
Answer the question
In order to leave comments, you need to log in
Hmm ... Yes, everything is simpler.
Throw packs, and that's all.
/**
* @Route("/articles")
* @Method("PUT")
*/
public function putArticlesAction(array $articles)
{
foreach ($articles as $article) {
$this->putArticleAction($article);
}
}
/**
* @Route("/articles/{article}")
* @Method("PUT")
*/
public function putArticleAction($article)
{
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question