FIXED: [api] sort socialactions by ordering

https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/677
This commit is contained in:
Mathieu Jaumotte 2022-12-08 14:03:04 +01:00
parent 5a93e21758
commit 8e65b3851a

View File

@ -13,7 +13,9 @@ namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Pagination\PaginatorInterface;
use Chill\MainBundle\Serializer\Model\Collection;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
@ -41,7 +43,12 @@ class SocialWorkSocialActionApiController extends ApiController
throw $this->createNotFoundException('socialIssue not found');
}
$socialActions = $socialIssue->getRecursiveSocialActions();
$socialActions = $socialIssue->getRecursiveSocialActions()->toArray();
usort($socialActions, function (SocialAction $sa, SocialAction $sb) {
return $sa->getOrdering() <=> $sb->getOrdering();
});
$pagination = $this->paginator->create(count($socialActions));
// max one page
$pagination->setItemsPerPage(count($socialActions));