diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php index a0d15b6db..4d6cfd82d 100644 --- a/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php @@ -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));