diff --git a/src/Plugin/PdfBackend/LocalServerPdfBackend.php b/src/Plugin/PdfBackend/LocalServerPdfBackend.php index fc16ad141b962a4f1c7d1d584bbf613fd77ac212..30f889638fbbd11d881e2e3e60e348600d51f277 100644 --- a/src/Plugin/PdfBackend/LocalServerPdfBackend.php +++ b/src/Plugin/PdfBackend/LocalServerPdfBackend.php @@ -10,9 +10,8 @@ use Drupal\fillpdf\FieldMapping\TextFieldMapping; use Drupal\fillpdf\Plugin\PdfBackendBase; use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Utils; use Symfony\Component\DependencyInjection\ContainerInterface; -use function GuzzleHttp\json_decode; -use function GuzzleHttp\json_encode; /** * LocalServer PdfBackend plugin. @@ -85,7 +84,7 @@ class LocalServerPdfBackend extends PdfBackendBase implements ContainerFactoryPl 'pdf' => base64_encode($pdf_content), ]; - $json = json_encode($request); + $json = Utils::jsonEncode($request); $fields = []; @@ -107,7 +106,7 @@ class LocalServerPdfBackend extends PdfBackendBase implements ContainerFactoryPl } } - $fields = json_decode((string) $fields_response->getBody(), TRUE); + $fields = Utils::jsonDecode((string) $fields_response->getBody(), TRUE); return $fields; } @@ -158,7 +157,7 @@ class LocalServerPdfBackend extends PdfBackendBase implements ContainerFactoryPl 'fields' => $api_fields, ]; - $json = json_encode($request); + $json = Utils::jsonEncode($request); try { $response = $this->httpClient->post($this->configuration['local_service_endpoint'] . '/api/v1/merge', [ @@ -166,7 +165,7 @@ class LocalServerPdfBackend extends PdfBackendBase implements ContainerFactoryPl 'headers' => ['Content-Type' => 'application/json'], ]); - $decoded = json_decode((string) $response->getBody(), TRUE); + $decoded = Utils::jsonDecode((string) $response->getBody(), TRUE); return base64_decode($decoded['pdf']); } catch (RequestException $e) {