mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-28 13:06:13 +00:00
Feature: Force language when converting documents
This commit is contained in:
parent
4a30f310b8
commit
d1bdf41c4c
@ -18,6 +18,7 @@ use Chill\MainBundle\Entity\User;
|
|||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||||
use Symfony\Component\Mime\Part\DataPart;
|
use Symfony\Component\Mime\Part\DataPart;
|
||||||
@ -40,6 +41,8 @@ class Convert
|
|||||||
|
|
||||||
private LoggerInterface $logger;
|
private LoggerInterface $logger;
|
||||||
|
|
||||||
|
private RequestStack $requestStack;
|
||||||
|
|
||||||
private Security $security;
|
private Security $security;
|
||||||
|
|
||||||
private StoredObjectManagerInterface $storedObjectManager;
|
private StoredObjectManagerInterface $storedObjectManager;
|
||||||
@ -49,12 +52,14 @@ class Convert
|
|||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
HttpClientInterface $httpClient,
|
HttpClientInterface $httpClient,
|
||||||
|
RequestStack $requestStack,
|
||||||
Security $security,
|
Security $security,
|
||||||
StoredObjectManagerInterface $storedObjectManager,
|
StoredObjectManagerInterface $storedObjectManager,
|
||||||
LoggerInterface $logger,
|
LoggerInterface $logger,
|
||||||
ParameterBagInterface $parameters
|
ParameterBagInterface $parameters
|
||||||
) {
|
) {
|
||||||
$this->httpClient = $httpClient;
|
$this->httpClient = $httpClient;
|
||||||
|
$this->requestStack = $requestStack;
|
||||||
$this->security = $security;
|
$this->security = $security;
|
||||||
$this->storedObjectManager = $storedObjectManager;
|
$this->storedObjectManager = $storedObjectManager;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
@ -68,6 +73,10 @@ class Convert
|
|||||||
}
|
}
|
||||||
|
|
||||||
$content = $this->storedObjectManager->read($storedObject);
|
$content = $this->storedObjectManager->read($storedObject);
|
||||||
|
$query = [];
|
||||||
|
if (null !== $request = $this->requestStack->getCurrentRequest()) {
|
||||||
|
$query['lang'] = $request->getLocale();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$url = sprintf('%s/cool/convert-to/pdf', $this->collaboraDomain);
|
$url = sprintf('%s/cool/convert-to/pdf', $this->collaboraDomain);
|
||||||
@ -76,6 +85,7 @@ class Convert
|
|||||||
]);
|
]);
|
||||||
$response = $this->httpClient->request('POST', $url, [
|
$response = $this->httpClient->request('POST', $url, [
|
||||||
'headers' => $form->getPreparedHeaders()->toArray(),
|
'headers' => $form->getPreparedHeaders()->toArray(),
|
||||||
|
'query' => $query,
|
||||||
'body' => $form->bodyToString(),
|
'body' => $form->bodyToString(),
|
||||||
'timeout' => 10,
|
'timeout' => 10,
|
||||||
]);
|
]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user