mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'master' into upgrade-php82
This commit is contained in:
commit
97a4c39941
@ -257,12 +257,10 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
/**
|
||||
* Add a social issue.
|
||||
*
|
||||
* Note: the social issue consistency (the fact that only yougest social issues
|
||||
* Note: the social issue consistency (the fact that only youngest social issues
|
||||
* are kept) is processed by an entity listener:
|
||||
*
|
||||
* @see{\Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodSocialIssueConsistencyEntityListener}
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addSocialIssue(SocialIssue $socialIssue): self
|
||||
{
|
||||
@ -270,6 +268,10 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
$this->socialIssues[] = $socialIssue;
|
||||
}
|
||||
|
||||
if ($this->getAccompanyingPeriod() !== null) {
|
||||
$this->getAccompanyingPeriod()->addSocialIssue($socialIssue);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -550,6 +552,10 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
{
|
||||
$this->accompanyingPeriod = $accompanyingPeriod;
|
||||
|
||||
foreach ($this->getSocialIssues() as $issue) {
|
||||
$this->accompanyingPeriod->addSocialIssue($issue);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ class ActivityContext implements
|
||||
$options = $template->getOptions();
|
||||
|
||||
$data = [];
|
||||
$data = array_merge($data, $this->baseContextData->getData());
|
||||
$data = array_merge($data, $this->baseContextData->getData($contextGenerationData['creator'] ?? null));
|
||||
$data['activity'] = $this->normalizer->normalize($entity, 'docgen', ['docgen:expects' => Activity::class, 'groups' => 'docgen:read']);
|
||||
|
||||
$data['course'] = $this->normalizer->normalize($entity->getAccompanyingPeriod(), 'docgen', ['docgen:expects' => AccompanyingPeriod::class, 'groups' => 'docgen:read']);
|
||||
|
@ -2,8 +2,8 @@ Budget: Budget
|
||||
Resource: Inkomsten
|
||||
Charge: Onkosten
|
||||
Budget for %name%: Budget van %name%
|
||||
Budget for household %household%: Budget van gezin
|
||||
Current budget household members: Actuele budget van gezinsleden
|
||||
Budget for household %household%: Budget van huishouden
|
||||
Current budget household members: Actuele budget van leden huishouden
|
||||
Show budget of %name%: Toon budget van %name%
|
||||
See complete budget: Toon volledige budget
|
||||
Hide budget: Verbergen
|
||||
|
@ -158,7 +158,7 @@ final class CalendarContext implements CalendarContextInterface
|
||||
$options = $this->getOptions($template);
|
||||
|
||||
$data = array_merge(
|
||||
$this->baseContextData->getData(),
|
||||
$this->baseContextData->getData($contextGenerationData['creator'] ?? null),
|
||||
[
|
||||
'calendar' => $this->normalizer->normalize($entity, 'docgen', ['docgen:expects' => Calendar::class, 'groups' => ['docgen:read']]),
|
||||
]
|
||||
|
@ -205,7 +205,7 @@ final class CalendarContextTest extends TestCase
|
||||
?NormalizerInterface $normalizer = null
|
||||
): CalendarContext {
|
||||
$baseContext = $this->prophesize(BaseContextData::class);
|
||||
$baseContext->getData()->willReturn(['base_context' => 'data']);
|
||||
$baseContext->getData(null)->willReturn(['base_context' => 'data']);
|
||||
|
||||
$personRender = $this->prophesize(PersonRender::class);
|
||||
$personRender->renderString(Argument::type(Person::class), [])->willReturn('person name');
|
||||
|
@ -21,18 +21,14 @@ class BaseContextData
|
||||
{
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(Security $security, NormalizerInterface $normalizer)
|
||||
public function __construct(NormalizerInterface $normalizer)
|
||||
{
|
||||
$this->security = $security;
|
||||
$this->normalizer = $normalizer;
|
||||
}
|
||||
|
||||
public function getData(): array
|
||||
public function getData(?User $user = null): array
|
||||
{
|
||||
$data = [];
|
||||
$user = $this->security->getUser();
|
||||
|
||||
$data['creator'] = $this->normalizer->normalize(
|
||||
$user instanceof User ? $user : null,
|
||||
|
@ -18,6 +18,7 @@ use Chill\DocGeneratorBundle\GeneratorDriver\DriverInterface;
|
||||
use Chill\DocGeneratorBundle\GeneratorDriver\Exception\TemplateException;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\DocStoreBundle\Service\StoredObjectManagerInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
@ -64,7 +65,8 @@ class Generator implements GeneratorInterface
|
||||
array $contextGenerationDataNormalized,
|
||||
?StoredObject $destinationStoredObject = null,
|
||||
bool $isTest = false,
|
||||
?File $testFile = null
|
||||
?File $testFile = null,
|
||||
?User $creator = null
|
||||
): ?string {
|
||||
if ($destinationStoredObject instanceof StoredObject && StoredObject::STATUS_PENDING !== $destinationStoredObject->getStatus()) {
|
||||
$this->logger->info(self::LOG_PREFIX.'Aborting generation of an already generated document');
|
||||
@ -89,6 +91,7 @@ class Generator implements GeneratorInterface
|
||||
|
||||
$contextGenerationDataNormalized = array_merge(
|
||||
$contextGenerationDataNormalized,
|
||||
['creator' => $creator],
|
||||
$context instanceof DocGeneratorContextWithPublicFormInterface ?
|
||||
$context->contextGenerationDataDenormalize($template, $entity, $contextGenerationDataNormalized)
|
||||
: []
|
||||
|
@ -13,6 +13,7 @@ namespace Chill\DocGeneratorBundle\Service\Generator;
|
||||
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
|
||||
interface GeneratorInterface
|
||||
@ -31,6 +32,7 @@ interface GeneratorInterface
|
||||
array $contextGenerationDataNormalized,
|
||||
?StoredObject $destinationStoredObject = null,
|
||||
bool $isTest = false,
|
||||
?File $testFile = null
|
||||
?File $testFile = null,
|
||||
?User $creator = null
|
||||
): ?string;
|
||||
}
|
||||
|
@ -15,7 +15,9 @@ use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
||||
use Chill\DocGeneratorBundle\Service\Generator\Generator;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\DocStoreBundle\Repository\StoredObjectRepository;
|
||||
use Chill\MainBundle\Repository\UserRepositoryInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException;
|
||||
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
|
||||
|
||||
@ -32,18 +34,28 @@ class RequestGenerationHandler implements MessageHandlerInterface
|
||||
|
||||
private Generator $generator;
|
||||
|
||||
private LoggerInterface $logger;
|
||||
|
||||
private UserRepositoryInterface $userRepository;
|
||||
|
||||
public const AUTHORIZED_TRIALS = 5;
|
||||
|
||||
private const LOG_PREFIX = '[docgen message handler] ';
|
||||
|
||||
public function __construct(
|
||||
DocGeneratorTemplateRepository $docGeneratorTemplateRepository,
|
||||
EntityManagerInterface $entityManager,
|
||||
Generator $generator,
|
||||
StoredObjectRepository $storedObjectRepository
|
||||
LoggerInterface $logger,
|
||||
StoredObjectRepository $storedObjectRepository,
|
||||
UserRepositoryInterface $userRepository
|
||||
) {
|
||||
$this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository;
|
||||
$this->entityManager = $entityManager;
|
||||
$this->generator = $generator;
|
||||
$this->logger = $logger;
|
||||
$this->storedObjectRepository = $storedObjectRepository;
|
||||
$this->userRepository = $userRepository;
|
||||
}
|
||||
|
||||
public function __invoke(RequestGenerationMessage $message)
|
||||
@ -60,6 +72,8 @@ class RequestGenerationHandler implements MessageHandlerInterface
|
||||
throw new UnrecoverableMessageHandlingException('maximum number of retry reached');
|
||||
}
|
||||
|
||||
$creator = $this->userRepository->find($message->getCreatorId());
|
||||
|
||||
$destinationStoredObject->addGenerationTrial();
|
||||
$this->entityManager->createQuery('UPDATE '.StoredObject::class.' s SET s.generationTrialsCounter = s.generationTrialsCounter + 1 WHERE s.id = :id')
|
||||
->setParameter('id', $destinationStoredObject->getId())
|
||||
@ -69,7 +83,16 @@ class RequestGenerationHandler implements MessageHandlerInterface
|
||||
$template,
|
||||
$message->getEntityId(),
|
||||
$message->getContextGenerationData(),
|
||||
$destinationStoredObject
|
||||
$destinationStoredObject,
|
||||
false,
|
||||
null,
|
||||
$creator
|
||||
);
|
||||
|
||||
$this->logger->info(self::LOG_PREFIX.'Request generation finished', [
|
||||
'template_id' => $message->getTemplateId(),
|
||||
'destination_stored_object' => $message->getDestinationStoredObjectId(),
|
||||
'duration_int' => (new \DateTimeImmutable('now'))->getTimestamp() - $message->getCreatedAt()->getTimestamp(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ class RequestGenerationMessage
|
||||
|
||||
private array $contextGenerationData;
|
||||
|
||||
private \DateTimeImmutable $createdAt;
|
||||
|
||||
public function __construct(
|
||||
User $creator,
|
||||
DocGeneratorTemplate $template,
|
||||
@ -39,6 +41,7 @@ class RequestGenerationMessage
|
||||
$this->entityId = $entityId;
|
||||
$this->destinationStoredObjectId = $destinationStoredObject->getId();
|
||||
$this->contextGenerationData = $contextGenerationData;
|
||||
$this->createdAt = new \DateTimeImmutable('now');
|
||||
}
|
||||
|
||||
public function getCreatorId(): int
|
||||
@ -65,4 +68,9 @@ class RequestGenerationMessage
|
||||
{
|
||||
return $this->contextGenerationData;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): \DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ use Chill\MainBundle\Repository\RegroupmentRepository;
|
||||
use Exception;
|
||||
use Symfony\Component\Form\DataMapperInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use function array_key_exists;
|
||||
use function count;
|
||||
|
||||
class ExportPickCenterDataMapper implements DataMapperInterface
|
||||
@ -29,7 +30,7 @@ class ExportPickCenterDataMapper implements DataMapperInterface
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return mixed
|
||||
* @return void
|
||||
*/
|
||||
public function mapDataToForms($data, $forms)
|
||||
{
|
||||
@ -72,12 +73,14 @@ class ExportPickCenterDataMapper implements DataMapperInterface
|
||||
$centers[spl_object_hash($center)] = $center;
|
||||
}
|
||||
|
||||
if (array_key_exists('regroupment', $forms)) {
|
||||
foreach ($forms['regroupment']->getData() as $regroupment) {
|
||||
/** @var Regroupment $regroupment */
|
||||
foreach ($regroupment->getCenters() as $center) {
|
||||
$centers[spl_object_hash($center)] = $center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = array_values($centers);
|
||||
}
|
||||
|
@ -253,8 +253,8 @@ No options availables. Your report is fully configured.: Geen beschikbare opties
|
||||
Ungrouped exports: Overige expor
|
||||
|
||||
#export download
|
||||
Download export: Téléchargement du rapport
|
||||
Waiting for your report: En attente de votre rapport
|
||||
Download export: Downloaden van rapport
|
||||
Waiting for your report: Wachten op je rapport
|
||||
Download your report: Télécharger votre rapport
|
||||
Problem during download: Problème durant le téléchargement
|
||||
# sans valeur
|
||||
|
@ -59,6 +59,7 @@
|
||||
:placeholder="$t('referrer.placeholder')"
|
||||
v-model="value"
|
||||
@select="updateReferrer"
|
||||
@remove="removeReferrer"
|
||||
:options="users"
|
||||
:select-label="$t('multiselect.select_label')"
|
||||
:deselect-label="$t('multiselect.deselect_label')"
|
||||
@ -194,6 +195,17 @@ export default {
|
||||
});
|
||||
this.toggleModal()
|
||||
},
|
||||
removeReferrer() {
|
||||
console.log('remove option')
|
||||
this.$store.dispatch('updateReferrer', null)
|
||||
.catch(({name, violations}) => {
|
||||
if (name === 'ValidationException' || name === 'AccessException') {
|
||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'})
|
||||
}
|
||||
});
|
||||
},
|
||||
cancelChange() {
|
||||
this.value = this.$store.state.accompanyingCourse.user
|
||||
this.toggleModal()
|
||||
|
@ -207,7 +207,7 @@ class AccompanyingPeriodContext implements
|
||||
$options = $template->getOptions();
|
||||
|
||||
$data = [];
|
||||
$data = array_merge($data, $this->baseContextData->getData());
|
||||
$data = array_merge($data, $this->baseContextData->getData($contextGenerationData['creator'] ?? null));
|
||||
$data['course'] = $this->normalizer->normalize($entity, 'docgen', ['docgen:expects' => AccompanyingPeriod::class, 'groups' => 'docgen:read']);
|
||||
|
||||
foreach (['mainPerson', 'person1', 'person2'] as $k) {
|
||||
|
@ -165,7 +165,7 @@ final class PersonContext implements PersonContextInterface
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data = array_merge($data, $this->baseContextData->getData());
|
||||
$data = array_merge($data, $this->baseContextData->getData($contextGenerationData['creator'] ?? null));
|
||||
$data['person'] = $this->normalizer->normalize($entity, 'docgen', [
|
||||
'docgen:expects' => Person::class,
|
||||
'groups' => ['docgen:read'],
|
||||
|
@ -54,7 +54,7 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator
|
||||
$activities = $this->activityRepository->findBy(['accompanyingPeriod' => $period]);
|
||||
|
||||
foreach ($activities as $activity) {
|
||||
$socialIssues = $activity->getSocialIssues()->toArray();
|
||||
$socialIssues = array_merge($socialIssues, $activity->getSocialIssues()->toArray());
|
||||
}
|
||||
|
||||
foreach ($period->getWorks() as $work) {
|
||||
@ -64,7 +64,7 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator
|
||||
$socialIssuesByKey = [];
|
||||
|
||||
foreach ($socialIssues as $si) {
|
||||
$socialIssuesByKey[$si->getId()] = $si;
|
||||
$socialIssuesByKey[spl_object_hash($si)] = $si;
|
||||
}
|
||||
|
||||
$periodIssuesWithAncestors = [];
|
||||
@ -75,7 +75,7 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator
|
||||
$periodIssuesWithAncestors,
|
||||
array_map(
|
||||
static function (SocialIssue $si) {
|
||||
return $si->getId();
|
||||
return spl_object_hash($si);
|
||||
},
|
||||
$si->getAncestors(true)
|
||||
)
|
||||
|
@ -125,7 +125,7 @@ address_country_code: Landscode
|
||||
'Alreay existing person': 'Reeds bestaand persoonsdossier'
|
||||
'Add the person': 'Persoon toevoegen'
|
||||
'Add the person and create an accompanying period': "Persoon & hulpverleningstraject aanmaken"
|
||||
'Add the person and create a household': "Persoon & gezin aanmaken"
|
||||
'Add the person and create a household': "Persoon & huishouden aanmaken"
|
||||
Show person: Toon persoonsdossier
|
||||
'Confirm the creation': 'Aanmaak dossier bevestigen'
|
||||
'You will create this person': 'U zal het volgende dossier aanmaken'
|
||||
@ -177,9 +177,9 @@ An accompanying period ends: Een hulpverleningstraject loopt op zijn einde
|
||||
An accompanying period starts: Een hulpverleningstraject gaat van start
|
||||
Any accompanying periods are open: Geen enkel hulpverleningstraject open
|
||||
An accompanying period is open: Een hulpverleningstraject staat open
|
||||
Accompanying period list: Hulpverleningstraject
|
||||
Accompanying period list: Hulpverleningstrajecten
|
||||
Accompanying period list for person: Hulpverleningstrajecten van persoon
|
||||
Accompanying period: Hulpverleningstraject
|
||||
Accompanying period: Hulpverleningstrajecten
|
||||
Any accompanying period: Geen enkel hulpverleningstraject
|
||||
period: Hulpverleningstraject
|
||||
New accompanying course: Nieuw hulpverleningstraject
|
||||
@ -215,8 +215,8 @@ No resources: "Geen hulpverlening partners"
|
||||
Persons associated: Betrokken personen
|
||||
Referrer: Doorverwijzer
|
||||
Referrers: Doorverwijzers
|
||||
Some peoples does not belong to any household currently. Add them to an household soon: Sommige personen maken nog geen deel uit van een gezin. Voeg ze zo snel mogelijk aan gezin toe.
|
||||
Add to household now: Toevoegen aan een gezin
|
||||
Some peoples does not belong to any household currently. Add them to an household soon: Sommige personen maken nog geen deel uit van een huishouden. Voeg ze zo snel mogelijk aan huishouden toe.
|
||||
Add to household now: Toevoegen aan een huishouden
|
||||
Any resource for this accompanying course: Geen enkele hulpverlening partner
|
||||
course.draft: Ontwerp
|
||||
course.closed: Afgesloten
|
||||
@ -458,7 +458,7 @@ Accompanying course location: Locatie van hulpverleningstraject
|
||||
This course is located by: Locatie bij
|
||||
This course has a temporarily location: Voorlopige locatie
|
||||
Choose a person to locate by: Adres van persoon toewijzen
|
||||
Associate at least one member with an household, and set an address to this household: Associeer minstens één betrokken persoon in dit hulpverleningstraject met een gezin en wijs een adres toe aan dit gezin.
|
||||
Associate at least one member with an household, and set an address to this household: Associeer minstens één betrokken persoon in dit hulpverleningstraject met een huishouden en wijs een adres toe aan dit huishouden.
|
||||
Locate by: Adres toewijzen
|
||||
fix it: Aanvullen
|
||||
accompanying_course:
|
||||
@ -480,23 +480,23 @@ accompanying_course_comment:
|
||||
Read more: Meer lezen..
|
||||
|
||||
# Household
|
||||
Household: Gezin
|
||||
Household: Huishouden
|
||||
Summary: Samenvatting
|
||||
Members: Gezinsleden
|
||||
Members: Leden huishouden
|
||||
Addresses: Addressen
|
||||
Move household: Nieuwe verhuis
|
||||
Addresses history for household: Historiek adressen
|
||||
Household accompanying period: Hulpverleningstrajecten van gezin
|
||||
Household summary: Samenvatting gezin
|
||||
Edit household address: Adres gezin bijwerken
|
||||
Show household: Gezin bekijken
|
||||
Back to household: Terugkeren naar gezin
|
||||
Remove household composition: Gezinssamenstelling verwijderen
|
||||
Are you sure you want to remove this composition?: Bent u zeker deze gezinssamenstelling te willen verwijderen?
|
||||
Concerns household n°%id%: Betrokken gezin n°%id%
|
||||
Composition: Gezinssamenstelling
|
||||
Household accompanying period: Hulpverleningstrajecten van huishouden
|
||||
Household summary: Samenvatting huishouden
|
||||
Edit household address: Adres huishouden bijwerken
|
||||
Show household: huishouden bekijken
|
||||
Back to household: Terugkeren naar huishouden
|
||||
Remove household composition: huishoudenssamenstelling verwijderen
|
||||
Are you sure you want to remove this composition?: Bent u zeker deze huishoudenssamenstelling te willen verwijderen?
|
||||
Concerns household n°%id%: Betrokken huishouden n°%id%
|
||||
Composition: huishoudenssamenstelling
|
||||
Budget: Budget
|
||||
The composition has been successfully removed.: De gezinssamenstelling werd verwijdert.
|
||||
The composition has been successfully removed.: De huishoudenssamenstelling werd verwijdert.
|
||||
|
||||
# accompanying course work
|
||||
Accompanying Course Actions: Hulpverleningsmaatregelen
|
||||
@ -560,16 +560,16 @@ You are getting a notification for a period you are not allowed to see: De notif
|
||||
This is the minimal period details: Hulpverleningstraject n°
|
||||
|
||||
household_composition:
|
||||
No composition yet: Geen enkele gezinssamenstelling toegewezen
|
||||
Compositions: Gezinssamenstelling
|
||||
No composition yet: Geen enkele huishoudenssamenstelling toegewezen
|
||||
Compositions: huishoudenssamenstelling
|
||||
endDate: Einddatum
|
||||
numberOfChildren: Aantal kinderen in het gezin
|
||||
Household composition: Gezinssamenstelling
|
||||
Composition added: Informatie over de gezinssamenstelling toegevoegd
|
||||
Currently no composition: Geen enkele gezinssamenstelling toegewezen
|
||||
Add a composition: Een gezinssamenstelling toevoegen
|
||||
Update composition: Gezinssamenstelling bijwerken
|
||||
Create: Een nieuwe gezinssamenstelling toewijzen
|
||||
numberOfChildren: Aantal kinderen in het huishouden
|
||||
Household composition: huishoudenssamenstelling
|
||||
Composition added: Informatie over de huishoudenssamenstelling toegevoegd
|
||||
Currently no composition: Geen enkele huishoudenssamenstelling toegewezen
|
||||
Add a composition: Een huishoudenssamenstelling toevoegen
|
||||
Update composition: huishoudenssamenstelling bijwerken
|
||||
Create: Een nieuwe huishoudenssamenstelling toewijzen
|
||||
|
||||
# docgen
|
||||
Linked evaluations: Gerelateerde evaluaties
|
||||
|
@ -18,6 +18,7 @@ use Chill\MainBundle\Entity\User;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Mime\Part\DataPart;
|
||||
@ -40,6 +41,8 @@ class Convert
|
||||
|
||||
private LoggerInterface $logger;
|
||||
|
||||
private RequestStack $requestStack;
|
||||
|
||||
private Security $security;
|
||||
|
||||
private StoredObjectManagerInterface $storedObjectManager;
|
||||
@ -49,12 +52,14 @@ class Convert
|
||||
*/
|
||||
public function __construct(
|
||||
HttpClientInterface $httpClient,
|
||||
RequestStack $requestStack,
|
||||
Security $security,
|
||||
StoredObjectManagerInterface $storedObjectManager,
|
||||
LoggerInterface $logger,
|
||||
ParameterBagInterface $parameters
|
||||
) {
|
||||
$this->httpClient = $httpClient;
|
||||
$this->requestStack = $requestStack;
|
||||
$this->security = $security;
|
||||
$this->storedObjectManager = $storedObjectManager;
|
||||
$this->logger = $logger;
|
||||
@ -68,18 +73,23 @@ class Convert
|
||||
}
|
||||
|
||||
$content = $this->storedObjectManager->read($storedObject);
|
||||
$query = [];
|
||||
if (null !== $request = $this->requestStack->getCurrentRequest()) {
|
||||
$query['lang'] = $request->getLocale();
|
||||
}
|
||||
|
||||
try {
|
||||
$url = sprintf('%s/cool/convert-to/pdf', $this->collaboraDomain);
|
||||
$form = new FormDataPart([
|
||||
'data' => new DataPart($content, $storedObject->getUuid()->toString(), $storedObject->getType()),
|
||||
]);
|
||||
$response = $this->httpClient->request('POST', $url, [
|
||||
'headers' => $form->getPreparedHeaders()->toArray(),
|
||||
'query' => $query,
|
||||
'body' => $form->bodyToString(),
|
||||
'timeout' => 10,
|
||||
]);
|
||||
|
||||
try {
|
||||
return new Response($response->getContent(), Response::HTTP_OK, [
|
||||
'Content-Type' => 'application/pdf',
|
||||
]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user