src/Controller/Api/CollaboratorController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Api;
  3. use App\Entity\Collaborator;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. class CollaboratorController extends ApiController
  8. {
  9.     /**
  10.      * @param Request $request
  11.      * @return JsonResponse
  12.      *
  13.      * @Route("/collaborator/list", name="api_collaborator_list", methods={"POST"})
  14.      */
  15.     public function listCollaborator(Request $request)
  16.     {
  17.         $prefixFile $this->getParameter("app.path.collaborator_images");
  18.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  19.         $collaborators = [];
  20.         
  21.         /** @var Collaborator $collaborator */
  22.         
  23.         foreach ($this->em->getRepository(Collaborator::class)->findAll() as $collaborator) {
  24.             $collaborators[] = $collaborator->__toArray($baseurl $prefixFile "/");
  25.             
  26.         }
  27.         return $this->response($collaborators);
  28.     }
  29. }