Skip to content

Commit

Permalink
fix(common/mime-types): add XLIFF mimetype support (#1097)
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 authored Dec 9, 2024
1 parent f3224d0 commit 3c44ada
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions EMS/common-bundle/src/Storage/Processor/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,8 @@ public static function fixFileExtension(string $filename, string $mimeType): str
'application/vnd.ms-excel' => 'xls',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx',
'application/xml' => 'xml',
'application/x-xliff+xml' => 'xlf',
'application/xliff+xml' => 'xlf',
'image/x-xpixmap' => 'xpm',
'image/x-xwindowdump' => 'xwd',
'text/yaml' => 'yml',
Expand Down
12 changes: 10 additions & 2 deletions EMS/core-bundle/src/Command/Xliff/ExtractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
[
EmsFields::CONTENT_FILE_HASH_FIELD => $hash,
EmsFields::CONTENT_FILE_NAME_FIELD => \basename($this->xliffBasename),
EmsFields::CONTENT_MIME_TYPE_FIELD => MimeTypes::APPLICATION_XML->value,
EmsFields::CONTENT_MIME_TYPE_FIELD => $this->getMimetype(),
],
[],
'ems_asset',
Expand Down Expand Up @@ -229,8 +229,16 @@ private function sendEmail(TempFile $tempFile): void
'query' => $this->searchQuery,
'fields' => $this->fields,
]);
$mailTemplate->addAttachment($tempFile->path, \basename($this->xliffBasename), MimeTypes::APPLICATION_XML->value);
$mailTemplate->addAttachment($tempFile->path, \basename($this->xliffBasename), $this->getMimetype());

$this->mailerService->sendMailTemplate($mailTemplate);
}

private function getMimetype(): string
{
return match ($this->xliffVersion) {
Extractor::XLIFF_1_2 => MimeTypes::APPLICATION_XLIFF_LEGACY->value,
default => MimeTypes::APPLICATION_XLIFF->value,
};
}
}
2 changes: 2 additions & 0 deletions EMS/helpers/src/Html/MimeTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
enum MimeTypes: string
{
case APPLICATION_ZIP = 'application/zip';
case APPLICATION_XLIFF_LEGACY = 'application/x-xliff+xml';
case APPLICATION_XLIFF = 'application/xliff+xml';
case APPLICATION_XML = 'application/xml';
case APPLICATION_OCTET_STREAM = 'application/octet-stream';
case IMAGE_PNG = 'image/png';
Expand Down

0 comments on commit 3c44ada

Please sign in to comment.