<?php
namespace App\Controller\Api;
use App\Entity\Vacancy;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class DataTypesController extends AbstractController
{
protected NormalizerInterface $normalizer;
/**
* EducationSearchController constructor.
*/
public function __construct(NormalizerInterface $normalizer)
{
$this->normalizer = $normalizer;
}
/**
* @throws ExceptionInterface
* @throws \JsonException
*/
#[Route(path: '/classes.js', name: 'fetch_datatype_classes_js')]
public function index(): Response
{
$vacancyMap = (new Vacancy())
->setTitle('')
;
$dataMap = [
'vacancy' => $this->normalizer->normalize($vacancyMap),
];
$response = new Response();
$response->headers->set('Content-Type', 'application/javascript');
return $this->render('api/datatypes.js.twig', [
'datamap' => json_encode($dataMap, \JSON_THROW_ON_ERROR),
], $response);
}
}