<?php
namespace App\Controller\Api;
use App\Entity\Position;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
class PositionController extends ApiController
{
/**
* @param Request $request
* @return JsonResponse
*
* @Route("/position/list", name="api_position_list", methods={"POST"})
*/
public function listPosition(Request $request)
{
$prefixFile = $this->getParameter("app.path.position_images");
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
$positions = [];
/** @var Position $position */
foreach ($this->em->getRepository(Position::class)->findAll() as $position){
$positions[] = $position->__toArray($baseurl . $prefixFile . "/");
}
return $this->response($positions);
}
}