Add image type + NotConserved

This commit is contained in:
2024-11-15 16:14:43 +01:00
parent b1c9fdbdf7
commit 54332fab42
9 changed files with 416 additions and 2 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Entity;
use App\ImageType;
use App\Repository\ImageRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
@@ -30,6 +31,9 @@ class Image implements \JsonSerializable
#[ORM\Column(name: 'ordine', type: Types::SMALLINT)]
private ?int $sequence = null;
#[ORM\Column(name: 'tipo')]
private ?string $type = null;
public function getId(): ?int
{
return $this->id;
@@ -102,6 +106,20 @@ class Image implements \JsonSerializable
return $this;
}
public function getType(): string
{
$type = ImageType::from($this->type);
return $type->name;
}
public function setType(ImageType $type): static
{
$this->type = $type->value;
return $this;
}
public function jsonSerialize(): array
{
return [
@@ -109,6 +127,7 @@ class Image implements \JsonSerializable
'filename' => $this->filename,
'caption' => $this->caption,
'author' => $this->author,
'type' => $this->getType(),
];
}
}