Skip to content

Commit

Permalink
Export logo
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarchois committed Nov 26, 2024
1 parent f2cc008 commit dabce6f
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 17 deletions.
Binary file modified data/regulation-order-template.docx
Binary file not shown.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
- '8080:8080'
volumes:
- ./:/var/www/dialog
- ./public/storage:/var/www/dialog/public/storage
- ./docker/php/php.ini:/usr/local/etc/php/php.ini
depends_on:
- database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function __invoke(GetGeneralInfoQuery $query): GeneralInfoView
uuid: $row['uuid'],
identifier: $row['identifier'],
organizationName: $row['organizationName'],
organizationLogo: $row['organizationLogo'],
organizationUuid: $row['organizationUuid'],
status: $row['status'],
regulationOrderUuid: $row['regulationOrderUuid'],
Expand Down
1 change: 1 addition & 0 deletions src/Application/Regulation/View/GeneralInfoView.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function __construct(
public readonly string $uuid,
public readonly string $identifier,
public readonly string $organizationName,
public readonly string $organizationLogo,
public readonly ?string $organizationUuid,
public readonly string $status,
public readonly string $regulationOrderUuid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
use App\Application\Regulation\Query\Measure\GetMeasuresQuery;
use App\Application\Regulation\Query\Visa\GetVisasAndReasonsByRegulationOrderQuery;
use App\Application\Regulation\View\GeneralInfoView;
use App\Application\StorageInterface;
use App\Domain\Regulation\Specification\CanOrganizationAccessToRegulation;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\HeaderUtils;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
Expand All @@ -24,6 +26,7 @@ public function __construct(
CanOrganizationAccessToRegulation $canOrganizationAccessToRegulation,
Security $security,
private readonly \Twig\Environment $twig,
private readonly StorageInterface $storage,
private readonly string $projectDir,
) {
parent::__construct($queryBus, $security, $canOrganizationAccessToRegulation);
Expand All @@ -46,13 +49,18 @@ public function __invoke(string $uuid): Response
$visasAndReasons = $this->queryBus->handle(new GetVisasAndReasonsByRegulationOrderQuery($generalInfo->regulationOrderUuid));
$signingAuthority = $this->queryBus->handle(new GetSigningAuthorityByOrganizationQuery($generalInfo->organizationUuid));
$measures = $this->queryBus->handle(new GetMeasuresQuery($uuid));

$fs = new Filesystem();
$logo = $generalInfo->organizationLogo ? base64_encode($fs->readFile($this->storage->get($generalInfo->organizationLogo))) : null;

$content = $this->twig->render(
name: 'regulation/export.md.twig',
context: [
'visasAndReasons' => $visasAndReasons,
'generalInfo' => $generalInfo,
'measures' => $measures,
'signingAuthority' => $signingAuthority,
'logo' => $logo,
],
);

Expand All @@ -61,7 +69,6 @@ public function __invoke(string $uuid): Response
->from('markdown')
->input($content)
->option('reference-doc', $this->projectDir . '/data/regulation-order-template.docx')
->option('resource-path', $this->projectDir . '/public/images')
->to('docx')
->run(),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public function findGeneralInformation(string $uuid): ?array
ro.identifier,
org.name as organizationName,
org.uuid as organizationUuid,
org.logo as organizationLogo,
roc.status,
ro.uuid as regulationOrderUuid,
ro.category,
Expand Down
19 changes: 3 additions & 16 deletions templates/regulation/export.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,10 @@
[{{ signingAuthority.address|raw|nl2br }}]{custom-style="Dialog_ACompleter"}
:::
{% endif %}
<br/>

::: {custom-style="Dialog_Encart"}
[Information importante :]{custom-style="Dialog_GrasSouligne"}

Ce document est un [modèle à compléter et à modifier]{custom-style="Dialog_Gras"}
par vos soins. Il constitue simplement une aide à la rédaction de l'arrêté, mais
ne garantit pas l'exactitude des informations. Il vous appartient de vérifier que
toutes les informations sont correctes.

• Les informations en [bleu]{custom-style="Dialog_VariableGras"} sont issues du formulaire, assurez-vous qu'elles soient toujours en cohérence avec les informations renseignées dans DiaLog.

• Les informations en [italique]{custom-style="Dialog_ACompleter"} sont à compléter.

Vous pouvez supprimer cet encart une fois votre arrêté complété.
:::

{% if logo %}
![](data:image/png;base64,{{ logo }}){ height=100px }
{% endif %}
<br/>

::: {custom-style="Dialog_TitrePrincipal"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function testGetGeneralInformation(): void
uuid: '3d1c6ec7-28f5-4b6b-be71-b0920e85b4bf',
identifier: 'FO1/2024',
organizationName: 'DiaLog',
organizationLogo: '/path/to/logo.jpg',
organizationUuid: 'a8439603-40f7-4b1e-8a35-cee9e53b98d4',
status: RegulationOrderRecordStatusEnum::DRAFT->value,
regulationOrderUuid: 'fce8177b-3737-4b4e-933d-fe29d0092c89',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function testView(): void
uuid: '3d1c6ec7-28f5-4b6b-be71-b0920e85b4bf',
identifier: 'FO1/2024',
organizationName: 'DiaLog',
organizationLogo: '/path/to/logo.jpg',
organizationUuid: 'a8439603-40f7-4b1e-8a35-cee9e53b98d4',
status: RegulationOrderRecordStatusEnum::DRAFT->value,
regulationOrderUuid: 'ed97924b-bdc5-421a-b6e8-ac3ee6b16a7e',
Expand All @@ -34,6 +35,7 @@ public function testView(): void
uuid: '3d1c6ec7-28f5-4b6b-be71-b0920e85b4bf',
identifier: 'FO1/2024',
organizationName: 'DiaLog',
organizationLogo: '/path/to/logo.jpg',
organizationUuid: 'a8439603-40f7-4b1e-8a35-cee9e53b98d4',
status: RegulationOrderRecordStatusEnum::PUBLISHED->value,
regulationOrderUuid: '8a32e881-a683-4caa-976f-6882296bc29b',
Expand Down

0 comments on commit dabce6f

Please sign in to comment.