socialIssueRepository = $socialIssueRepository; $this->paginator = $paginator; } public function listBySocialIssueApi($id, Request $request) { $socialIssue = $this->socialIssueRepository ->find($id); if (null === $socialIssue) { throw $this->createNotFoundException('socialIssue not found'); } $socialActions = $socialIssue->getRecursiveSocialActions(); $pagination = $this->paginator->create(count($socialActions)); // max one page $pagination->setItemsPerPage(count($socialActions)); $collection = new Collection($socialActions, $pagination); return $this->json($collection, JsonResponse::HTTP_OK, [], ['groups' => ['read']]); } }