Fix the appellation selection for projet professional

This commit is contained in:
Julie Lenaerts 2024-05-23 12:46:12 +02:00
parent 33a6f9996e
commit a5c2576124
2 changed files with 14 additions and 24 deletions

View File

@ -65,30 +65,23 @@ class PartenaireRomeAppellation
{ {
$bearer = $this->getBearer(); $bearer = $this->getBearer();
$request = new Request('GET', 'appellation');
$parameters = [
'query' => [
'q' => $search,
'fq' => 'libelle',
],
'headers' => [
'Authorization' => 'Bearer '.$bearer,
],
];
try { try {
$response = $this->handleRequest( $response = $this->httpClient->request(
$request, 'GET', self::BASE . 'appellation/requete', [
$parameters, 'headers' => [
$this->client, 'Authorization' => 'Bearer '.$bearer,
$this->logger 'Accept' => 'application/json',
); ],
'query' => [
'q' => $search
],
]
);
return Utils::jsonDecode((string) $response->getBody()); return $response->toArray()['resultats'];
} catch (ClientException $e) { } catch (HttpExceptionInterface $exception) {
dump($e->getResponse()->getBody()->getContents()); throw $exception;
} }
return new Response('No appellation found');
} }
public function getAppellation($code) public function getAppellation($code)

View File

@ -50,9 +50,6 @@ class RomeAppellationChoiceLoader implements ChoiceLoaderInterface
*/ */
protected $validator; protected $validator;
/**
* RomeAppellationChoiceLoader constructor.
*/
public function __construct( public function __construct(
EntityManagerInterface $em, EntityManagerInterface $em,
PartenaireRomeAppellation $apiAppellation, PartenaireRomeAppellation $apiAppellation,