make sure to generate valid filenames (#2238)

This commit is contained in:
Kevin Papst
2021-01-08 14:50:23 +01:00
committed by GitHub
parent a5fdf81df5
commit 244169d6d5
7 changed files with 80 additions and 14 deletions

View File

@@ -10,7 +10,7 @@
namespace App\Invoice;
use App\Entity\Project;
use Symfony\Component\String\UnicodeString;
use App\Utils\FileHelper;
final class InvoiceFilename
{
@@ -31,8 +31,7 @@ final class InvoiceFilename
}
if (!empty($company)) {
$uCompany = new UnicodeString($company);
$filename .= '-' . $uCompany->ascii()->snake();
$filename .= '-' . $this->convert($company);
}
if (null !== $model->getQuery()) {
@@ -40,8 +39,7 @@ final class InvoiceFilename
if (\count($projects) === 1) {
$pName = $projects[0];
if ($pName instanceof Project) {
$uProject = new UnicodeString($pName->getName());
$filename .= '-' . $uProject->ascii()->snake();
$filename .= '-' . $this->convert($pName->getName());
}
}
}
@@ -49,6 +47,11 @@ final class InvoiceFilename
$this->filename = $filename;
}
private function convert(string $filename): string
{
return FileHelper::convertToAsciiFilename($filename);
}
public function getFilename()
{
return $this->filename;