<?php
namespace App\Controller\Api;
use App\Entity\Collaborator;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class CollaboratorController extends ApiController
{
/**
* @param Request $request
* @return JsonResponse
*
* @Route("/collaborator/list", name="api_collaborator_list", methods={"POST"})
*/
public function listCollaborator(Request $request)
{
$prefixFile = $this->getParameter("app.path.collaborator_images");
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
$collaborators = [];
/** @var Collaborator $collaborator */
foreach ($this->em->getRepository(Collaborator::class)->findAll() as $collaborator) {
$collaborators[] = $collaborator->__toArray($baseurl . $prefixFile . "/");
}
return $this->response($collaborators);
}
}