mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-03-01 04:49:36 +00:00
Improved LabelGenerationProcessor
This commit is contained in:
parent
1e28817280
commit
dbe42198ea
1 changed files with 6 additions and 1 deletions
|
|
@ -58,6 +58,10 @@ class LabelGenerationProcessor implements ProcessorInterface
|
|||
throw new AccessDeniedHttpException('You do not have permission to generate labels.');
|
||||
}
|
||||
|
||||
if (!$data instanceof LabelGenerationRequest) {
|
||||
throw new BadRequestHttpException('Invalid request data for label generation.');
|
||||
}
|
||||
|
||||
/** @var LabelGenerationRequest $request */
|
||||
$request = $data;
|
||||
|
||||
|
|
@ -113,6 +117,7 @@ class LabelGenerationProcessor implements ProcessorInterface
|
|||
// Generate filename
|
||||
$filename = $this->generateFilename($elements[0], $profile);
|
||||
|
||||
|
||||
// Return PDF as response
|
||||
return new Response(
|
||||
$pdfContent,
|
||||
|
|
@ -127,7 +132,7 @@ class LabelGenerationProcessor implements ProcessorInterface
|
|||
|
||||
private function generateFilename(AbstractDBElement $element, LabelProfile $profile): string
|
||||
{
|
||||
$ret = 'label_' . $this->elementTypeNameGenerator->getLocalizedTypeLabel($element);
|
||||
$ret = 'label_' . $this->elementTypeNameGenerator->typeLabel($element);
|
||||
$ret .= $element->getID();
|
||||
$ret .= '_' . preg_replace('/[^a-z0-9_\-]/i', '_', $profile->getName());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue