Use the name of an uploaded file for an attachment when no explicit name was set.

This commit is contained in:
Jan Böhmer 2023-03-05 23:47:45 +01:00
parent 4a30819ea5
commit 52e459ec60
3 changed files with 40 additions and 6 deletions

View file

@ -25,6 +25,7 @@ namespace App\Entity\Attachments;
use App\Entity\Base\AbstractNamedDBElement;
use App\Validator\Constraints\Selectable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use function in_array;
use InvalidArgumentException;
@ -95,6 +96,14 @@ abstract class Attachment extends AbstractNamedDBElement
*/
protected string $path = '';
/**
* @var string the name of this element
* @ORM\Column(type="string")
* @Assert\NotBlank(message="validator.attachment.name_not_blank")
* @Groups({"simple", "extended", "full"})
*/
protected string $name = '';
/**
* ORM mapping is done in sub classes (like PartAttachment).
*/