mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Using HttpClientInterface instead of file_get_contents
This commit is contained in:
parent
2993dab3f7
commit
0e88d7c549
@ -37,13 +37,17 @@ use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
final class DocGeneratorTemplateController extends AbstractController
|
||||
{
|
||||
private KernelInterface $kernel;
|
||||
private HttpClientInterface $client;
|
||||
|
||||
public function __construct(KernelInterface $kernel)
|
||||
public function __construct(KernelInterface $kernel, HttpClientInterface $client)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,7 +67,7 @@ final class DocGeneratorTemplateController extends AbstractController
|
||||
'GET',
|
||||
$template->getFile()->getFilename());
|
||||
|
||||
$data = file_get_contents($getUrlGen->url);
|
||||
$data = $this->client->request('GET', $getUrlGen->url);
|
||||
|
||||
$iv = $template->getFile()->getIv(); // iv as an Array
|
||||
$ivGoodFormat = pack('C*', ...$iv); // iv as a String (ok for openssl_decrypt)
|
||||
@ -73,7 +77,7 @@ final class DocGeneratorTemplateController extends AbstractController
|
||||
$key = $template->getFile()->getKeyInfos()['k'];
|
||||
$keyGoodFormat = Base64Url::decode($key);
|
||||
|
||||
$dataDecrypted = openssl_decrypt($data, $method, $keyGoodFormat, 1, $ivGoodFormat);
|
||||
$dataDecrypted = openssl_decrypt($data->getContent(), $method, $keyGoodFormat, 1, $ivGoodFormat);
|
||||
|
||||
if ($dataDecrypted === FALSE) {
|
||||
throw new \Exception("Error during Decrypt ", 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user